After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 119126 - Wrongly evaluated key when context node is in temporal RTF
Wrongly evaluated key when context node is in temporal RTF
Status: VERIFIED NOTABUG
Product: libxslt
Classification: Platform
Component: general
1.0.29
Other Windows
: Normal normal
: ---
Assigned To: Daniel Veillard
Daniel Veillard
Depends on:
Blocks:
 
 
Reported: 2003-08-04 20:47 UTC by jirka
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description jirka 2003-08-04 20:47:24 UTC
When you invoke key() function and context node is in temporal result tree 
fragment (e.g. constructed by node-set() function), key() function does 
return nothing even there is corresponding node in the source document. See 
attached files for demonstration of error.

--- test.xsl --
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:exsl="http://exslt.org/common"
                extension-element-prefixes="exsl"
                version="1.0">
  
  <!-- Make key for all elements with id attribute -->
  <xsl:key name="id" match="*[@id]" use="@id"/>

  <xsl:template match="/">

    <!-- Copy whole document as RTF into variable -->
    <xsl:variable name="rtf">
      <xsl:copy-of select="."/>
    </xsl:variable>

    <!-- Convert RTF back to nodeset -->
    <xsl:variable name="nodes" select="exsl:node-set($rtf)"/>

    <!-- Apply templates to nodeset -->
    <xsl:apply-templates select="$nodes/*"/>

  </xsl:template>  

  <xsl:template match="link">
    <xsl:text>Target content:</xsl:text>
    <!-- Lookup content of element with specified id in a source document 
-->
    <xsl:value-of select="key('id', @target)"/>
    <!-- And there is error, it prints nothing instead of content of 
referenced element -->
  </xsl:template>

  <xsl:template match="text()"/>

</xsl:stylesheet>

--- test.xml ---
<test>
<link target="b"/>
<section id="b">Foo</section>
</test>
Comment 1 Daniel Veillard 2003-08-04 21:21:21 UTC
If I do understand correctly, the current document is the RTF copy
which as the node-set() extension sub-specify acts like a new document.
The keys are not computed on that document, this is not a stated
requirement. On the other hand the definition for key() in the
XSLT-1.0 spec states:
   - The key function does for keys what the id function does for IDs.
   - and the id() function states clearly:
     "the result is a node-set containing the elements in the same   
      document as the context node that..."
The context document is the RTF. It has no key index, there is no
semantic associated to key for result of node-set() as far as I can 
tell, there is nothing at
   http://exslt.org/exsl/functions/node-set/index.html
indicating any other processing than doing the conversion...
So nothing in the specs indicate that id() or key() should work
when the current node is in the result of a node-set()

  Conclusion: your stylesheet relies on totally unspecified behaviour
              I have a hard time accepting as a bug, but if you
              have further evidence, I would take them...

Daniel

P.S.: I hardly see this as a major or critical bug ...
Comment 2 Daniel Veillard 2003-09-13 19:56:50 UTC
No new information, I think we can close this now,

Daniel