This content has been marked as final.
Show 3 replies
-
1. Re: Is there a way to give a Java Document an XML schema for XPath queries
jtahlborn Feb 5, 2013 3:24 PM (in response to davidthi808-JavaNet)you can provide a schema when parsing an xml document in order to check for schema conformance, but that isn't going to affect your XPath queries at all. DOM content is never anything but strings. -
2. Re: Is there a way to give a Java Document an XML schema for XPath queries
davidthi808-JavaNet Feb 5, 2013 3:47 PM (in response to jtahlborn)jtahlborn wrote:
In the case of both dom4j/jaxen and the .NET runtime the values returned from XPath queries when a schema is provided are typed. So you get back numbers, dates, and booleans as well as strings. And for numbers you get correct comparisons so 20 > 1.
you can provide a schema when parsing an xml document in order to check for schema conformance, but that isn't going to affect your XPath queries at all. DOM content is never anything but strings. -
3. Re: Is there a way to give a Java Document an XML schema for XPath queries
jtahlborn Feb 5, 2013 7:34 PM (in response to davidthi808-JavaNet)DavidThi808 wrote:
i guess it's possible. i use schemas when parsing xml, and i've used xpath (infrequently), but i'm not sure that i've ever used them together in a way that i would see functionality like that.jtahlborn wrote:
In the case of both dom4j/jaxen and the .NET runtime the values returned from XPath queries when a schema is provided are typed. So you get back numbers, dates, and booleans as well as strings. And for numbers you get correct comparisons so 20 > 1.
you can provide a schema when parsing an xml document in order to check for schema conformance, but that isn't going to affect your XPath queries at all. DOM content is never anything but strings.
FYI, you use http://docs.oracle.com/javase/6/docs/api/javax/xml/parsers/DocumentBuilderFactory.html#setSchema%28javax.xml.validation.Schema%29 to specify a schema while parsing with a DocumentBuilder.