Re: How we are being silently manipulated - a fresh example - Was: Re: QT4CG meeting 120 draft minutes, 6 May 2025

I think we are all well aware that the handling of empty sequences in path expressions is a mixed blessing: it means that $BOOK / AUTHOR / NAME returns the names of all the authors of the book whether the book has 0, 1, or many authors; but at the same time it means that if the element name AUTHOR is misspelled, no error is reported. 

In 3.1 we reproduced this behaviour with lookup of fields in records ($BOOK ? AUTHOR ? NAME), and this PR extended this to lookup with methods ($BOOK ? AUTHOR() ? NAME()). The construct $BOOK ! AUTHOR ! NAME also follows the same pattern - emptiness is propagated down the path, rather than being treated as erroneous. Consistency is important for usability, and this handling of hierarchic selection paths is absolutely intrinsic to the style and character of XPath as a language.

Since it is not an error for a book to have no authors, there is no "swallowing" of any error - the expression is not erroneous so there is no error to swallow, and this applies to all these cases.

The corrollory that XPath doesn't detect misspelled selectors in a path is indeed a serious problem that costs developers hours of effort. This was recognized soon after XPath 1.0 and the introduction of schema awareness was an attempt to solve it, with mixed success. I think the functions such as exactly-one() were also introduced with this in mind; the idea was that if you expected a book to have exactly one author, you could write $BOOK/exactly-one(AUTHOR)/exactly-one(NAME). But hardly anyone does so; people will always write the code that is easiest to write, rather than the code that is most robust.

But the rule about a dynamic function call requiring a singleton wasn't really a solution to that problem, it only detected it in a very small minority of cases, and it did so more by accident than by design.  We should look for better solutions to that problem, which is what issue 1979 strives to do.

Our modus operandi is for detailed technical discussions to take place in writing before we take a decision in a meeting. There is no need for all the technical arguments to be repeated verbally in the meeting - it is assumed that attendees have prepared for the meeting by reading the discussion thread.

Michael Kay

Received on Tuesday, 6 May 2025 17:54:55 UTC