You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Roland Illig (Jira)" <ji...@apache.org> on 2025/03/22 05:16:00 UTC
[jira] [Commented] (XALANJ-2244) xsl:sort does not work with nodeset parameters
[ https://issues.apache.org/jira/browse/XALANJ-2244?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17937544#comment-17937544 ]
Roland Illig commented on XALANJ-2244:
--------------------------------------
Still current, see https://stackoverflow.com/questions/79526199/sorting-nodes-in-a-named-template.
> xsl:sort does not work with nodeset parameters
> ----------------------------------------------
>
> Key: XALANJ-2244
> URL: https://issues.apache.org/jira/browse/XALANJ-2244
> Project: XalanJ2
> Issue Type: Bug
> Components: XSLTC
> Environment: JDK 1.5.0_06
> Reporter: Nicolas
> Priority: Major
> Attachments: XALANJ_2444_Test.java, bug.xslt
>
>
> i create some number elements within a variable, pass them to a function that extract the maximum value, and i get an empty result.
> this happens width jdk 1.5 default transformer, but not with Saxon transformer or jdk 1.4.2 default transformer.
> simple function to calculate the maximum value of some nodes passed as parameter :
> <xsl:template name="max">
> <xsl:param name="nodes" select="/.."/>
> <xsl:for-each select="$nodes">
> <xsl:sort data-type="number" order="descending"/>
> <xsl:if test="position() = 1">
> <xsl:value-of select="number(.)"/>
> </xsl:if>
> </xsl:for-each>
> </xsl:choose>
> </xsl:template>
> simple elements :
> <xsl:variable name="foo">
> <xsl:element name="bar">
> <xsl:text>5</xsl:text>
> </xsl:element>
> <xsl:element name="bar">
> <xsl:text>8</xsl:text>
> </xsl:element>
> <xsl:element name="bar">
> <xsl:text>2</xsl:text>
> </xsl:element>
> </xsl:variable>
> call the function :
> <xsl:variable name="result">
> <xsl:call-template name="max">
> <xsl:with-param name="nodes" select="nodeset($foo)/bar"/>
> </xsl:call-template>
> </xsl:variable>
> see the result :
> <xsl:value-of select="$result" /> is empty
> If i remove the <xsl:sort ...> line in the function, result is 5 (wich is logic)
> If i use the function inline, it works :
> <xsl:variable name="result">
> <xsl:for-each select="nodeset($foo)/bar">
> <xsl:sort data-type="number" order="descending"/>
> <xsl:if test="position() = 1">
> <xsl:value-of select="number(.)"/>
> </xsl:if>
> </xsl:for-each>
> </xsl:variable>
> <xsl:value-of select="$result" /> is 8
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xalan.apache.org
For additional commands, e-mail: dev-help@xalan.apache.org