Validate XML against XSD
To validate an XML Document against an XSD, you need to associate your XML Document with the XSD: Click Schema > Associate XML Document with DTD, Relax NG Schema, or XSD..., and select an XSD. 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 XSD "book.xsd". In this case, the XSD 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 XSD 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 XSD.
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