[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
XML Schema/attributeGroup and namespaces
- From: Stefan Krause <stf@snafu.de>
- To: xml-dev@lists.xml.org
- Date: Tue, 27 May 2008 21:42:34 +0200
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
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]