Been wondering, just as we use the -declaration to bind XML to a DTD, how do we do it with XSD?
MSDN sample:
<?xml version='1.0'?> <Product ProductID='123' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='Product.xsd'> <ProductName>Rugby jersey</ProductName> </Product>
is it the xsi:NoNamespaceSchemaLocation that does the trick? Or is this just another namespace?
[EDIT] And is the
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
..line just for giving us a unique XML namespace, or does it also provide information on where the schema can be located?
Try schemaLocation.
noNamespaceSchemaLocation is different. Note that both are indeed only ‘hints’ in theory, to a consumer of an XML document. I’ve never run into an xml processor that did not follow them; after all, it’s a W3C recommendation. see http://www.w3.org/TR/xmlschema-1/
But indeed, it could go wrong, as here, but then again, it’s considered a bug for a reason.
To go short : I just trust it, with no harm so far 🙂
I don’t think any half-decent xml processor can ignore this ‘hint’ these days.
The urls are always for uniqueness, but in some cases some info will be provided under the URL.