Using the extension mechanism described in the section Extensibility, additional constraints can be specified that can be used by applications that process the data corresponding to the grammar defined in the schema. When you use XML Schema, the XML DOM provides a property on each element and attribute to quickly access its definition in the schema. The definition property on the IXMLDOMNode interface returns the corresponding ElementType or AttributeType from the schema. Recall that since an XML Schema document is itself an XML document, the schema can be parsed into a tree of nodes like any other XML document. The XML DOM can then be used to navigate the schema. For example, use the example schema and the following XML document:
<book> <title>Presenting XML</title> <author>Richard Light</author> <pages>334</pages> </book>
Start by getting the root element (assuming the document has been parsed, and the pointer "doc" refers to the parsed document):
var bookNode = doc.documentElement; var pagesNode = doc.documentElement.lastChild;
You can now use the definition property on "pagesNode" to get the ElementType for pages.
var pagesET = pagesNode.definition;
With "pagesET," you can then access the extended information present in the schema.
var minPages = pagesET.childNodes(1).text; var maxPages = pagesET.childNodes(2).text;