Reputation: 8346
I have a very simple XML & XSD which is throwing following error during parsing.
org.xml.sax.SAXParseException: s4s-elt-schema-ns: The namespace of element 'Config' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.
XML Goes here :
<?xml version="1.0" encoding="ISO-8859-1" ?>
<Config>
<Test Script="final.sh" />
</Config>
XSD Goes here:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Config">
<xs:complexType>
<xs:all>
<xs:element name="Test" minOccurs="0">
<xs:complexType>
<xs:attribute name="Script" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
Upvotes: 0
Views: 9206
Reputation: 423
I tried it out in Oxygen and document was valid.
here are the two files I used:
xsd file:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation='schema.xsd'>
<Test Script="final.sh" />
</Config>
xml file:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Config">
<xs:complexType>
<xs:all>
<xs:element name="Test" minOccurs="0">
<xs:complexType>
<xs:attribute name="Script" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
Make sure you attach xsd schema to xml file correctly, then it should be fine.
Upvotes: 1
Reputation: 163262
The instance document supplied is valid against the schema supplied, so there's something strange going on here.
The error message would seem to suggest that the schema you are actually validating against says
targetNamespace="http://www.w3.org/2001/XMLSchema"
which would be a rather odd thing for it to say.
I'm afraid you've been given a lot of very poor advice in other responses to your question.
Upvotes: 1