Re: [xml-dev] Be careful writing XPath expressions when the XML could have non-existent elements

From
John Cowan <>
To
Wendell Piez <>
Date
2014-07-30T16:39:03Z
ID
<CABzTEQBGWtkusEy8yXUiZdsVTiKBw8o-cao_7ic3-6mqB=>
Thread
Re: [xml-dev] Be careful writing XPath expressions when the XML could have non-existent elements

On Wed, Jul 30, 2014 at 10:49 AM, Wendell Piez <[email protected]> wrote:

But in the general case, I want select //div[@class='section'] to
return every div that has a 'class' attribute whose value is
'section', and none whose @class is something else, or not there at
all. So "@class='section'" returns false() when @class returns an
empty sequence (or node set in XPath 1.0.)

What do you want it to return: a run-time error?

Clearly not.  But what I could see would be an XSLT feature to make it an error
to match against a path that matches nothing.  There would need to be a way
to turn this on and off selectively, of course.

Separation of concerns suggests a Schematron schema would do better, though.

--
GMail doesn't have rotating .sigs, but you can see mine at http://www.ccil.org/~cowan/signatures