[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Group and display the min value [for each item]


Subject: [xsl] Group and display the min value [for each item]
From: "Giancarlo Rossi" <giancarlo_rossi@xxxxxxxxxx>
Date: Wed, 30 Aug 2006 09:18:19 +0200

I'm trying to get the min value from an xml file.

This code works but sometimes doesnt take the just min value and most of all
not sort the results in a ascending way.
Could you help me ?
Regards.

you could see The xml file in www.lastminutesud.it/test/last_mad_lgw.xlm


<xsl:key name="OutwardList" match="Outward"
use="SegmentList/Segment/Operator/Name"/>
<xsl:template match="/">
<xsl:for-each
select="//Outward[generate-id(.)=generate-id(key('OutwardList',SegmentList/S
egment/Operator/Name))]">
<xsl:sort select="Price/Amount" order="ascending" data-type="number"/>
<xsl:variable name="ok_op" select="SegmentList/Segment/Operator/Name" />

<xsl:variable name="min">
<xsl:for-each
select="//Outward[SegmentList/Segment/Operator/Name=$ok_op]/Price/Amount/tex
t()">
<xsl:sort select="." order="ascending" data-type="number"/> <xsl:if
test="position() = 1"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each>
</xsl:variable>

<xsl:value-of select="$min"/>

</xsl:for-each>
</xsl:template>


Current Thread
Keywords
xml