[ 
https://issues.apache.org/jira/browse/XALANC-624?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12464612
 ] 

David Bertoni commented on XALANC-624:
--------------------------------------

Patch to clean up the whole key retrieval process is attached.  Committers, can 
you please review?

> The key() function does not work when the context node is the root node of a 
> result tree fragment obtained through exsl:node-set()
> ----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XALANC-624
>                 URL: https://issues.apache.org/jira/browse/XALANC-624
>             Project: XalanC
>          Issue Type: Bug
>          Components: XalanC
>    Affects Versions: 1.10
>         Environment: winxp-sp2
>            Reporter: Alain Le Guennec
>         Assigned To: David Bertoni
>         Attachments: bug-key.xslt, patch.diff, StylesheetRoot.cpp
>
>
> The key() function does not work when the context node is the root node of a 
> result tree fragment obtained through exsl:node-set().
> Consider the following stylesheet (applied to any input document, the actual 
> input does not matter):
> <?xml version="1.0"  encoding = "ISO-8859-1"?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
> xmlns:exsl="http://exslt.org/common";>
>       <xsl:key name="lookup-by-name" match="*" use="local-name()"/>
>       <xsl:variable 
> name="test-tree-rtf"><N1><N2><N3></N3></N2></N1></xsl:variable>
>       <xsl:variable name="test-tree" 
> select="exsl:node-set($test-tree-rtf)/*"/>
>       <xsl:template match="/">
>               <!-- key() with context within the result tree fragment. -->
>               <xsl:for-each select="$test-tree">
>                       <xsl:for-each select=".">
>                               <xsl:variable name="n1" 
> select="key('lookup-by-name', 'N1')"/>
>                               <xsl:choose>
>                                       <xsl:when 
> test="count($n1)=1"><xsl:message>OK </xsl:message></xsl:when>
>                                       <xsl:otherwise><xsl:message>BUG 
> </xsl:message></xsl:otherwise>
>                               </xsl:choose>
>                       </xsl:for-each>
>               </xsl:for-each>
>               <!-- key() with context being the root of the result tree 
> fragment. -->
>               <xsl:for-each select="$test-tree">
>                       <xsl:for-each select="/">
>                               <xsl:variable name="n1" 
> select="key('lookup-by-name', 'N1')"/>
>                               <xsl:choose>
>                                       <xsl:when 
> test="count($n1)=1"><xsl:message>OK </xsl:message></xsl:when>
>                                       <xsl:otherwise><xsl:message>BUG 
> </xsl:message></xsl:otherwise>
>                               </xsl:choose>
>                       </xsl:for-each>
>               </xsl:for-each>
>       </xsl:template>
> </xsl:stylesheet>
> In the two cases, the key() function should return the N1 node belonging to 
> the result tree fragment
> (because the result tree fragment is acting as the "context document" in both 
> cases).
> However, it works only in the first case (it prints "OK"), not the second (it 
> prints "BUG").
> I could find that the cause of the bug is in the function getKeyNode() of 
> StylesheetRoot.cpp.
> This function does not work when the context node is a DOCUMENT_FRAGMENT_NODE 
> to start with.
> I rewrote it so that it works in that case too (see attachment).
> Best regards,
> Alain Le Guennec.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to