When you add an xml schema to a document like I understand that the xmlns is not actually the location of the xsd file. Is this correct?
- How do you in practice reference an xml file’s schema?
- Is it usually on a web server? That would seem very chatty.
- Is it referenced by relative path?
- Is it not actually referenced in the xml but rather loaded into an xml parser arbitrarily?
Any feedback?
You have a schema with a target namespace and qualified elements (wich means you don’t have to prefix your elements to apply target namespace):
You have to include it in your root element. First the xml-schema namespace:
(from here the
xsi:prefix corresponds to this namespace)Then reference the schemaLocation attribute
where
my.xsdis the location of the XSD file (by default relative to the XML document’s location). You can put a complete URL likeSo that gives your document:
Note that the XSD file URL is not necessarily related to the namespace URI.