Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Novice XSD namespace question

Status
Not open for further replies.

rss181919

Programmer
Feb 26, 2011
1
US
I have an xsd I am trying to link up to an xml so the xml content will be validated (see below). I am having trouble with namespaces. If you attempt to validate as is, it fails stating on the brushes element and the only way I can get it to work is to undeclare the default namespace on the xml root element. So I think I have a namespace conflict between the brushes element in the xsd and the brushes element in the xml. Can't figure out why that is. Any explanation is much appreciated.

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs=" targetNamespace="mynamespace">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="brushes">
<xs:complexType>
<xs:sequence>
<xs:element name="brush" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="type" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="image|video"></xs:pattern>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="uri" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="theme_references">
<xs:complexType>
<xs:sequence>
<xs:element name="theme_reference" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="id" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="icon_brush" type="xs:string" use="required"></xs:attribute>
<xs:attribute name="theme_uri" type="xs:string" use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


<?xml version="1.0" encoding="utf-8"?>
<root xmlns="mynamespace"
xmlns:xsi=" xsi:schemaLocation="mynamespace theme_references.xsd">
<brushes>
<brush id="alphabet_icon" type="image" uri="content\themes\alphabet\images\A.png"></brush>
</brushes>
<theme_references>
<theme_reference id="alphabet" icon_brush="alphabet_icon" theme_uri="content\themes\alphabet\alphabet.xml"></theme_reference>
</theme_references>
</root>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top