0
votes

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>
3
Use SW such as Oxygen to help you spot your errors. I think you miss namespace declaration in your xml file, put it into your root element, something like this: <Config xmlns:xs="http:// www.w3.org/2001/XMLSchema"> . Plus add document declaration to the věry top of your xml file.i-bob
can you give me the modification please ?logan
Tru this or something similar: <Config xmlns:xs="http:// www.w3.org/2001/XMLSchema"></Config>i-bob
Also you can put this <?xml version="1.0" encoding="ISO-8859-1" ?> to the věry top of your xml file.i-bob
Look to this resource so that you know what you are doping wrong www.w3schools.com/xml/xml_namespaces.aspi-bob

3 Answers

1
votes

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.

1
votes

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.

-1
votes

missing root namespace, add it to it