XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
RE: [xml-dev] XML Schema/attributeGroup and namespaces

Hi,

	The locally declared attribute such as "attr3" by default is
unqualified. You can't prefix it with the prefix associated with the
target namespace of the schema "bar.xsd". 
	To make it qualified, you can explicitly set the attribute
"attributeFormDefault" on the "schema" element to the value "qualified"
so that all locally declared attributes including the "attr3" would
belong to the target namespace "http://bar";.

Lisa


-----Original Message-----
From: Stefan Krause [mailto:stf@snafu.de] 
Sent: Tuesday, May 27, 2008 12:43 PM
To: xml-dev@lists.xml.org
Subject: [xml-dev] XML Schema/attributeGroup and namespaces

Hello,

I run into some difficulties while importing a xs:attributeGroups with
the right namespace. Look at this document:

== foo.xml ==
<?xml version="1.0" encoding="UTF-8"?>
<root
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
	xsi:noNamespaceSchemaLocation="foo.xsd"
	xmlns:bar="http://bar";>
	
	<element attr1="1" bar:attr2="2" bar:attr3="3"/>
</root>

The element has three attributes, attr1 is in the noNamespace, the
others are in the "http://bar"-namespace.

Here are the schemas:

== foo.xsd ==
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
	xmlns:xs="http://www.w3.org/2001/XMLSchema";
	elementFormDefault="qualified"
	xmlns:bar="http://bar";>
	<xs:import namespace="http://bar"; schemaLocation="bar.xsd"/>
	<xs:element name="root">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="element"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="element">
		<xs:complexType>
			<xs:attribute name="attr1"/>
			<xs:attribute ref="bar:attr2"/>
			<xs:attributeGroup ref="bar:group"/>
		</xs:complexType>
	</xs:element>
</xs:schema>

== bar.xsd ==
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
	xmlns:xs="http://www.w3.org/2001/XMLSchema";
	elementFormDefault="qualified"
	targetNamespace="http://bar";
	xmlns:bar="http://bar";>
	<xs:attribute name="attr2"/>
	<xs:attributeGroup name="group">
		<xs:attribute name="attr3"/>
		<xs:attribute name="attr4"/>
	</xs:attributeGroup>
</xs:schema>

While validating, attr1 and attr2 are OK, but attr3 raises an error. On
the other hand, putting attr3 in noNamespace (writing attr3 without the
prefix), also attr3 is OK.

I really need a straightforward way to import xs:attributeGroups from
external schemas into a separate namespace, so how can I do this?

Thanks for your advices,

Stefan

_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS