[ 
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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to