Hello, I'm facing a weird problem (IMHO) which, in short, is:
a node list passed as a parameter to a template can't be sorted. The problem occurs only if I do the transformation from within Ant (I use Ant 1.8.4). It does not occur if I perform it via a Java program or in XmlSpy or through http://xsltransform.net. Here's an example. The input file (a.xml) is: <root> <a>BBB</a> <a>AAA</a> </root> The transformation (trans.xml) is: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" /> <xsl:template match="/"> <Root> <xsl:call-template name="processThis"> <xsl:with-param name="nodeList" select="/*/a"/> </xsl:call-template> </Root> </xsl:template> <xsl:template name="processThis"> <xsl:param name="nodeList" /> <xsl:for-each select="$nodeList"> <xsl:sort /><!-- ***** This causes the problem --> <xsl:variable name="thisVal" select="." /> <result value="{$thisVal}" /> </xsl:for-each> </xsl:template> </xsl:stylesheet> The Ant script is: <project default="trans"> <target name="trans"> <delete file="out.xml"/> <xslt style="trans.xsl" in="a.xml" out="out.xml"/> </target> </project> The expected output is: <Root> <result value="AAA" /> <result value="BBB" /> </Root> But if I run the ant script, just an empty 'Root' element is generated, without child nodes. If I comment out the line marked with '*****', the generated Root element does contain child elements, but unsorted (as one would expect in this case). If I process the elements directly (and not in a template passing the list to process as a parameter), then I can use 'sort', and everything works as expected. Here is the 'direct' transformation: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" /> <xsl:template match="/"> <Root> <xsl:for-each select="/*/a"> <xsl:sort /> <xsl:variable name="thisVal" select="." /> <result value="{$thisVal}" /> </xsl:for-each> </Root> </xsl:template> </xsl:stylesheet> So my question is: why isn't a list passed as a parameter to a template processed with a 'sort' option -- in Ant? Thank you! AL --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org