I want to validate an XML file against an XSD schema. The XML files root element does not have any namespace or xsi details. It has no attributes so just
You have two separate concerns you need to take care of:
xsi:schemaLocation
attribute in the file to give a hint (!) where the schema is.You can safely skip the second part, as the location is really only a hint. You cannot skip the first part. The namespace declared in the XML file is matched against the schema. Important, this:
<xml> ... </xml>
Is not the same as this:
<xml xmlns="urn:foo"> ... </xml>
So you need to declare your namespace in the XML document, otherwise it will not correspond to your schema and you will get this error.