5

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.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
DavidA
  • 2,053
  • 6
  • 30
  • 54

1 Answers1

11

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:

kjhughes
  • 106,133
  • 27
  • 181
  • 240