<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29796</bug_id>
          
          <creation_ts>2016-08-26 19:34:28 +0000</creation_ts>
          <short_desc>[XSLT30] Keys and documents</short_desc>
          <delta_ts>2016-09-09 21:50:23 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XSLT 3.0</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>editorial</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Abel Braaksma">abel.braaksma</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>127244</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-08-26 19:34:28 +0000</bug_when>
    <thetext>I have to admit that I do not use keys that much, and today it came as a surprise that I couldn&apos;t use it with non-rooted nodes (that is, nodes that are not rooted at a document node).

Under xsl:key this is not explicit, in fact, we even say &quot;an xsl:key element applies to all nodes that match the pattern specified in the match attribute&quot;.

However, under fn:key we are explicit and even have an error if you inadvertently use the fn:key function with the 3rd argument (or the context node) on a node that has no document at its root (XTDE1270).

If the fn:key function is used in a pattern, this error would never be raised, but you would also never have a positive match.

I don&apos;t understand why we have this limitation, is it historical? I would like to drop it, it doesn&apos;t seem to make much sense and with the advent of allowing any kind of node or nodes as input to a stylesheet transformation, it is a limitation and complexity we can live without.

Note that we *do* require it to be applicable to temporary trees, so if the argument would be that it only applies to input trees from fn:doc etc, and that it is too much of a performance hit to remove this limitation, I don&apos;t think that it matters much in practice.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127245</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-08-26 20:58:54 +0000</bug_when>
    <thetext>I don&apos;t see a good justification to add this feature / lift this restriction at this stage of development of a spec that has already been almost ten years in the making.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127246</commentid>
    <comment_count>2</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-08-27 16:59:19 +0000</bug_when>
    <thetext>You&apos;re probably right. I figured it was an omission/oversight, but if that&apos;s not the case (or if the oversight is something we can live with), I agree we shouldn&apos;t change it.

That said: the sentence under xsl:key could benefit from mentioning that it only applies to document nodes, it would remove the discrepancy.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127247</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-08-27 17:17:11 +0000</bug_when>
    <thetext>Historically, when XPath 2.0 introduced the possibility of parentless element nodes (and text nodes etc) into the data model, we were concerned about the potential complexity and implementation overhead of allowing keys to apply to such nodes, and we made a conscious decision to exclude this possibility. Whether that decision is still justified is an open question, but I don&apos;t think that now is a good time to start reviewing and reconsidering it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127340</commentid>
    <comment_count>4</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-09-08 17:03:50 +0000</bug_when>
    <thetext>As discussed at today&apos;s meeting, the WG decided that we leave the functionality as-is, however, the editor was requested to write a small clarification, as per the suggestion in comment #2.

Reclassifying this as editorial.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127360</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-09-09 21:50:23 +0000</bug_when>
    <thetext>The requested note has been added.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>