I want to write a simple XML file with a custom xsd file located in the same local directory on my computer. I don't understand the necessary syntax at the beginning of the files (I have googled but XSD tutorials seem to focus on the element definitions rather than the xsd:schema
).
My sys_params.xsd begins:
<xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<xsd:element name="shipOrder" type="order"/>
My sys_params.xml begins:
<shiporder orderid="889923"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com sys_params.xsd"
<orderperson>John Smith</orderperson>
My XML reports this validation error on the xml:
Error schema document 'sys_params.xsd' has different target namespace from the one specified in instance document 'http://www.w3schools.com'
No doubt my code is quite wrong but I need some help to correct it please.
Change
xsi:schemaLocation="http://www.w3schools.com sys_params.xsd"
to
xsi:noNamespaceSchemaLocation="sys_params.xsd"
because your XML is not in a namespace.
See also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With