Tuesday, March 10, 2009

XSD Schema validation

There are some stuffs that one often configure once and just use it later on. But then it's hard to recall what has been done for it to work. One such example is setting the XSD schema for validation in XML files so this post is my cheat-sheet to avoid wasting my time looking on the Internet.

The main source can be found in http://www.xml.com/lpt/a/691

Dependent on using namespaces, the link will be either:

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file:library.xsd">

Or, as below (noting the syntax with a URI for the namespace and the URI of the schema, separated by whitespace in the same attribute):

 xmlns="http://example.org/ns/books/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://example.org/ns/books/ file:library.xsd">
Note that the "file:" has no triple slash

No comments: