Validate XML against XML Schema
To validate an XML Document against an XML Schema, you need to associate your XML Document with the XML Schema: Click Schema > Associate XML Document with DTD, Relax NG Schema, or XML Schema..., and select an XML Schema. You can also do this yourself, for example:
<book
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="book.xsd">
</book>
This tells XMLBlueprint to validate the XML Document against XML Schema "book.xsd". In this case, the XML 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:
xsi:noNamespaceSchemaLocation="https://www.xmlblueprint.com/schemas/book.xsd"> (correct - URL syntax)
xsi:noNamespaceSchemaLocation="file:///C:/XMLBlueprint/book.xsd"> (correct - URL syntax)
xsi:noNamespaceSchemaLocation="C:\XMLBlueprint\book.xsd"> (not correct - Path syntax)
If the XML Schema has a namespace, e.g., "urn:xmlblueprint-book-namespace", the syntax is a little different:
<book
xmlns="urn:xmlblueprint-book-namespace"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:xmlblueprint-book-namespace https://www.xmlblueprint.com/schemas/book.xsd"> ">
</book>
Note that the namespace must be equal to the targetNamespace defined in the XML Schema.
Open your XML Document in the XML Editor.
Click XML > Validate.
The Errors view is automatically displayed to show any errors in the XML Document. Click on the error message to jump to the position where the error occurred.
See Also