Re: [xml-dev] Schemaless XML?
Maybe Michael's concept of overriding XPaths
--
should handle the case where you want to
ensure /x/y always returns a single node and
not a nodeset. This might counter the idea of
keeping the result type the same for a given
XPath expression.
On Wednesday, 12 October 2016, Stephen D Green <[email protected]> wrote:
On Wednesday, 12 October 2016, Stephen D Green <[email protected]> wrote:
A key difference in handling schemaless XML and XML with a schema to which it should adhere is when constructing an XPath expression, knowing whether to say /x/y[1] or just /x/yIf there is a schema it will likely say whether or not y is limited to a single occurrence.If so then /x/y will always return a single node rather than nodeset.If not then you need /x/y[1] (or better) to ensure it does.Getting back a nodeset when you expect a node could break downstream code.True?It is likely the schema could change without your knowing it to loosen the cardinality by allowing multiple elements where before only single occurrences were allowed.So the issue remains even with a schema of sorts.I reckon if you are monitoring XML being passed around a network or the Internet you might be concerned to have a schema, else you would have to always cater for every element having multiple cardinality.Painful. Yet the schema could change at any time without a change of namespace so you are still kept on your toes.I think agile methods have led to these thingsbeing only very rarely discussed and little adviceprovided to developers.
------Stephen D Green
--
----
Stephen D Green