Reputation: 1588
I am trying to write my first XSD . . . The XSD is as follows and does not validate.
<xsd:schema elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="Hdr">
<xsd:sequence>
<xsd:element name="ID" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Header" type="xsd:Hdr" />
</xsd:schema>
I am using http://www.utilities-online.info/xsdvalidation/ for the validation
I get this error
Not valid.Error - Line 7, 49: org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 49; src-resolve.4.2: Error resolving component 'xsd:Hdr'. It was detected that 'xsd:Hdr' is in namespace 'http://www.w3.org/2001/XMLSchema', but components from this namespace are not referenceable from schema document 'null'. If this is the incorrect namespace, perhaps the prefix of 'xsd:Hdr' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'null'. Error - Line 7, 49: org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 49; src-resolve: Cannot resolve the name 'xsd:Hdr' to a(n) 'type definition' component.
I cannot figure out what is wrong in my XSD. Could someone please guide.
Upvotes: 2
Views: 433
Reputation: 111521
Change
<xsd:element name="Header" type="xsd:Hdr" />
to
<xsd:element name="Header" type="Hdr" />
If a target namespace were defined, you would use its prefix to reference Hdr
, but you'd never use the http://www.w3.org/2001/XMLSchema
namespace to make such a reference.
Upvotes: 2