This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
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.
The WG accepted the proposed change and it has been implemented.
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().
Correction, the grammar does currently allow an empty argument list.