This section describes a tutorial example on how to assign a schema location in an XML document without namespace using 'noNamespaceSchemaLocation' root attribute.
When you use an XML Schema processor to verify the validity an XML document against an XML Schema Definition (XSD) document,
the location of the XSD document can be specified to the processor in two ways:
Providing the schema location directly to the XML Schema processor.
Providing the schema location indirectly to the XML Schema processor by adding a special root attribute to the XML document.
In many XML editors, adding the schema location attribute to an XML document is called "Assigning XML Schema",
which requires 3 changes in the XML document:
1. Declare a new namespace prefix in the XML document called, "xsi", with a special attribute on the root element:
"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"". This is needed to provide the namespace prefix "xsi" for the next change.
2. If the XML document does not have its own namespace, specify the schema location with a special attribute
on the root element: "xsi:noNamespaceSchemaLocation="URL-of-schema"".
Let's use our simplest XSD schema file, hello.xsd, to test this:
Here is an XML document, hello.xml, that conforms to this schema. But it does not have the schema location assigned
in the XML document:
<?xml version="1.0"?>
<p>Hello world!</p>
Since there is no namespace used in the XML document, we can easily modify the XML document
to include the schema location. The resulting XML document is hello_xsd_no_namespace.xml: