I'm using XPath 1.0 to process incoming web services messages. This can be quite hard to get right if schema data types are used, because XPath 1.0 does not recognize them (XPath 2.0 does, but there seems to be no full open source implementation. Not sure if Saxon-B does this).
E.g., the literals "true" and "false" in a xs:boolean represent the boolean values True and False according to xml schema, but XPath 1.0 will evaluate both of them to True.
This means that evaluating /test
against <test>false</test>
actually returns True.
The same goes for other datatypes as well: "12.78e-2" is a valid value for xs:double, but evaluates to Double.NaN.
javax.xml.datatype
contains type mappings for duration and dateTime, but that's it.
XMLBeans contains easy to use converters between java and schema's built-in data types:
Node n = jaxp13XPathTemplate.evaluateAsNode(expression, context);
boolean b = XmlBoolean.Factory.parse(n).getBooleanValue();
Are there any other tools that might be helpful (and no, I'm not looking for a full-fledged XML binding framework)?