W3C home > Mailing lists > Public > public-qt-comments@w3.org > February 2005

RE: [xpath] non-document root nodes

From: Michael Kay <mhk@mhk.me.uk>
Date: Fri, 25 Feb 2005 15:51:13 -0000
To: "'Elliotte Harold'" <elharo@metalab.unc.edu>, <public-qt-comments@w3.org>
Message-ID: <E1D4hlA-0005W6-Ck@frink.w3.org>

> I'm concerned about the last two sentences of each of these 
> paragraphs.
> 
> In XOM, in XPath 1, I've found it useful to query trees with 
> no document 
> nodes above them by inserting a sort of pseudo-document node.

We did consider that approach, but decided that specifying it in such a way
that tidied up all the possible loose ends would be hopelessly complicated.
(As I know from experience, coding something is often a lot easier than
specifying it rigorously enough to satisfy a W3C WG).

Another approach would be the device used in specifying XSLT 2.0 patterns:
the "child-or-top" axis. But again, it's hardly elegant and extending it to
the demanding space of full path expressions would be quite troublesome. 

> This makes expressions like /a/b/c meaningful, whether or not the 
> context node is in a document.

I think it's actually a good idea in a multi-document environment to
encourage users to put a variable at the top: $x/a/b/c. There's still scope
for confusion, of course, as to whether $x refers to a document node or an
element node.

It's also possible, of course, to find the root of any tree using the root()
function.

The WGs have given quite a lot of thought to this subject: we're aware there
are usability pitfalls in this area, but decided that making "/" on orphan
trees an error would put some kind of fence around the problem that stopped
users falling in unawares.

Michael Kay (personal response).   
Received on Friday, 25 February 2005 15:52:08 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:23 UTC