Validating an XML Document against a Relax NG Schema

How to validate an XML Document against a Relax NG Schema

XMLBlueprint can validate any XML Document against any valid Relax NG Schema. Because the MSXML parser does not support Relax NG Schemas you need to use another XML validator, for example Jing, Libxml2, or MSV:
Open your XML Document in the XML Editor.
Click Tools > Jing or Tools > Libxml2 or Tools > MSV.
The Output Window is automatically displayed to show any errors in the XML Document.
Note: To validate an XML Document you need to associate your XML Document with a DTD, Relax NG Schema, or XML Schema.

How to associate your XML Document with a Relax NG Schema

To validate an XML Document against a Relax NG Schema, you need to associate your XML Document with the Relax NG Schema. XMLBlueprint uses a non standard, proprietary, processing instruction for this:
<?blueprint schema="book.rng"?>
<book>
</book>
This tells XMLBlueprint to validate the XML Document against Relax NG Schema "book.rng". In this case, the Relax NG Schema is to be found in the same folder as the XML Document. It is also possible to specify an absolute location, but beware that you must use URL syntax, not Path syntax. For example:
<?blueprint schema="http://www.xmlblueprint.com/schemas/book.rng"?> (correct - URL syntax)
<?blueprint schema="file:///C:/XMLBlueprint/book.rng"?> (correct - URL syntax)
<?blueprint schema="C:\XMLBlueprint\book.rng"?> (not correct - Path syntax)
If the Relax NG Schema has a namespace, e.g., "urn:xmlblueprint-book-namespace", the syntax is a little different:
<?blueprint namespace="urn:xmlblueprint-book-namespace" schema="book.rng"?>
<book xmlns="urn:xmlblueprint-book-namespace">
</book>
Note that the namespace must be equal to the target namespace (the 'ns' attribute of 'grammar') defined in the Relax NG Schema.

Copyright © 2002 - 2008 by Monkfish Software. All rights reserved.