XPath 2.0 atomization as a concept, as applicable to XML Schema 1.1 validation is worth looking at. I would attempt to write something about this topic, here in this blog post.
Lets look at the following XML Schema 1.1 validation example, that we'll use to discuss this topic.
XSD 1.1 document:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="X">
<xs:complexType>
<xs:sequence>
<xs:element name="a" type="xs:integer"/>
<xs:element name="b" type="xs:integer"/>
</xs:sequence>
<xs:assert test="a gt b"/>
</xs:complexType>
</xs:element>
</xs:schema>
XML instance document that is validated with above mentioned XSD document:
<?xml version="1.0"?>
<X>
<a>4</a>
<b>7</b>
</X>
Upon XML Schema validation, the above mentioned XML instance document would be reported as invalid, because numeric value of "a" is less than "b". Now what is XPath 2.0 atomization, as for in this example that I wish to talk about?
Since the XML document has been validated with the mentioned XSD document, while building the XPath data model tree to evaluate <assert>, the nodes of XPath tree are bound with the XSD types as mentioned in the XSD document. Therefore, the <assert> XPath 2.0 expression "a gt b", comes with runtime availability of the corresponding XSD types on <assert> tree nodes for elements "a" and "b". In XPath 2.0 terms, the values as a result of atomization operation of nodes for XML elements "a" and "b" are used when an XPath expression "a gt b" is evaluated. We can't test a greater/less than relation on XML nodes, but we can do that on numbers for example, and the conversion of XML runtime nodes to atomic values like number is what XPath 2.0 atomization achieves.
I've used Apache Xerces as an XSD 1.1 validator, for testing examples for this blog post.
No comments:
Post a Comment