Reputation: 8315
I've been looking for a way to attach an XSD to an XML file so that a program openning that XML can access to the corresponding XSD, but all the anwers i found included the use of a namespace without even a single explaination about it.
I only have an XSD, i don't have a "namespace" or whatever that is. How can i just reference my XSD into an XML file ?
Upvotes: 0
Views: 56
Reputation: 122364
If you have a schema without a targetNamespace
then you can attach it to a non-namespaced XML file using xsi:noNamespaceSchemaLocation
on the root element
<example xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="schema.xsd">
A validating parser will attempt to resolve the schema location as a relative URL against the location of the XML document, you may want to use an absolute URL rather than a relative one if the schema and document are not in the same place.
xsi:noNamespaceSchemaLocation="http://example.com/schema.xsd"
Upvotes: 1