In this release, schema validation has been integrated with the
regular SAXParser and DOMParser classes. No special classes are
required to parse documents that use a schema.
Each document that uses XML Schema grammars must specify the location of the
grammars it uses by using an xsi:schemaLocation attribute if they use
namespaces, and an xsi:noNamespaceSchemaLocation attribute
otherwise. These are usually placed on the root / top-level element
in the document, though they may occur on any element; for more details see XML
Schema Part 1 section 4.3.2.
Here is an example with no target namespace:
 |  |  |
 | <document
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation='document.xsd'>
...
</document> |  |
 |  |  |
Here is an example with a target namespace. Note that it is an
error to specify a different namespace than the target namespace
defined in the Schema.
 |  |  |
 | <document
xmlns='http://my.com'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://my.com document.xsd'>
...
</document> |  |
 |  |  |
Review the sample file, 'data/personal.xsd' for an example of an XML
Schema grammar.