[ 
http://issues.apache.org/jira/browse/XALANJ-2329?page=comments#action_12445492 
] 
            
Brian Minchau commented on XALANJ-2329:
---------------------------------------

My patch in XALANJ-2204 also fixes this problem, so when that issue is resolved 
this one should be too.

> sorting nodes in a variable mutates the variable (oops)
> -------------------------------------------------------
>
>                 Key: XALANJ-2329
>                 URL: http://issues.apache.org/jira/browse/XALANJ-2329
>             Project: XalanJ2
>          Issue Type: Bug
>          Components: DTM
>    Affects Versions: Latest Development Code
>            Reporter: Brian Minchau
>
> Testcase XSL
> ---------------------------------------------------------
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
> version="1.0">
>   <xsl:variable name="x" select="/doc/ch"/>
>   <xsl:template match="/">
>     <xsl:text>&#xa;</xsl:text>
>     <out>
>       <xsl:text>&#xa;</xsl:text>
>       <presort-foreach>
>         <xsl:for-each select="$x">
>           <xsl:copy-of select="."/>
>         </xsl:for-each>
>       </presort-foreach>
>       <xsl:text>&#xa;</xsl:text>
>       <sort-foreach>
>         <xsl:for-each select="$x">
>           <xsl:sort data-type="number" order="ascending"/>
>           <xsl:copy-of select="."/>
>         </xsl:for-each>
>       </sort-foreach>
>       <xsl:text>&#xa;</xsl:text>
>       <postsort-foreach>
>         <xsl:for-each select="$x">
>           <xsl:copy-of select="."/>
>         </xsl:for-each>
>       </postsort-foreach>
>       <xsl:text>&#xa;</xsl:text>
>     </out>
>   </xsl:template>
> </xsl:stylesheet>
> ---------------------------------------------------------
> Testcase XML:
> ---------------------------------------------------------
> <doc><ch>1</ch><ch>4</ch><ch>3</ch><ch>2</ch></doc>
> ---------------------------------------------------------
> The presort comes out in order 1 4 3 2.
> The sort comes out in order 1 2 3 4
> ... but then the postsort comes out in order 1 2 3 4, but should be in the 
> order 1 4 3 2, so the sort on $x has mutated
> the variable $x, and this is WRONG.
> Thanks to Henry Zongaro for thinking up this bug while reviewing my fix for 
> XALANJ-2204.
> <implementation-details>
> It looks like the cache, a NodeVector, held by a NodeSequence is being shared 
> and updated by the iterators.
> The fix might be to create your own copy of the cache when an attempt is made 
> to mutate it after it is complete.
> </implementation-details>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://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