[ http://issues.apache.org/jira/browse/XALANJ-2329?page=all ]
Brian Minchau closed XALANJ-2329. --------------------------------- This issue is resolved, and I am the reporter, so I'm closing the issue. > 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 > Fix For: Latest Development Code > > > 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>
</xsl:text> > <out> > <xsl:text>
</xsl:text> > <presort-foreach> > <xsl:for-each select="$x"> > <xsl:copy-of select="."/> > </xsl:for-each> > </presort-foreach> > <xsl:text>
</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>
</xsl:text> > <postsort-foreach> > <xsl:for-each select="$x"> > <xsl:copy-of select="."/> > </xsl:for-each> > </postsort-foreach> > <xsl:text>
</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]
