This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27126 - [XSLT30] allow fn:root in patterns to match parentless nodes
Summary: [XSLT30] allow fn:root in patterns to match parentless nodes
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Last Call drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-22 15:12 UTC by Abel Braaksma
Modified: 2015-10-29 09:50 UTC (History)
0 users

See Also:


Attachments

Description Abel Braaksma 2014-10-22 15:12:47 UTC
This bug report is to track the resolution of https://lists.w3.org/Archives/Member/w3c-xsl-wg/2014Oct/0018.html (member only).

This mail was discussed at the telcon of 16 October 2014. Summary of that discussion and the mail discussion:

Rationale:
* parentless¹ nodes are everywhere (xsl:variable with as="element()" for instance)
* we (now) have the ability to start stylesheet invocation with any kind of item, including parentless¹ nodes
* using a leading "/" in patterns won't match as it *must* match a document node, this often confuses users that consider it to match any root
* matching the root of parentless¹ nodes is tricky and very non-trivial, using patterns like "foo[not(..)]"
* using fn:root() would make such patterns clearer
* the relevant changes to the spec appear to be minimal

Points against:
* late in the game (2nd LCWD status)
* there is a workaround, "people should read tutorials"

The recorded DECISION at the telcon was to leave the decision of whether or not to include this change up to the editor.

¹ the term "parentless" here means any nodes without a parent, except for document-nodes.
Comment 1 Michael Kay 2014-10-24 14:17:23 UTC
The WG accepted the proposed change and it has been implemented.
Comment 2 Michael Kay 2014-10-24 15:00:35 UTC
This proved a little more complex than expected.

I decided that it made sense to only allow the zero-arity form of root(), because I don't want to extend what we allow in the argument list (which is currently restricted to literals and variable references). We still have to extend the rules for the argument list to allow it to be empty.

Restricting it to the zero-arity form seems to require an extra-grammatical rule, which is a little untidy but essentially manageable. The alternative would be to allow root($var), which is meaningful but not very useful. I don't particularly want to allow root(.) because that would open the way to things such as key('k', .)[1] which matches a node that is the first in its group by key value.

The semantics fofr root#0 seem to work OK: root()/self::E selects a node in the node-set root()//root()/self::E, which is fine, because root()//root() selects the same node as root().
Comment 3 Michael Kay 2014-10-24 15:02:49 UTC
Correction, the grammar does currently allow an empty argument list.