Subject: RE: [xsl] Get the maximum of a set of values From: "Babos, Andras" <ababos@xxxxxxxxxxxxx> Date: Wed, 3 Nov 2004 14:10:23 +0100 |
Hi Birgit, That's an interesting one... Try calling this template (lines might wrap around): <xsl:template name="GetMaxValue"> <xsl:param name="startIndex" select="1"/> <xsl:param name="maxValue" select="0"/> <xsl:variable name="leftOver" select="count (index/entry) - $startIndex"/> <xsl:choose> <xsl:when test="$leftOver < 1"> <xsl:variable name="lastNumber" select="document (concat (string (index/entry[position () = last ()]/xml), '.xml'))/entry/item/@number"/> <xsl:choose> <xsl:when test="$maxValue > $lastNumber"> <xsl:value-of select="$maxValue"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$lastNumber"/> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:variable name="currentValue" select="document (concat (string (index/entry[position () = $startIndex]/xml), '.xml'))/entry/item/@number"/> <xsl:call-template name="GetMaxValue"> <xsl:with-param name="startIndex" select="$startIndex + 1"/> <xsl:with-param name="maxValue"> <xsl:choose> <xsl:when test="$maxValue > $currentValue"> <xsl:value-of select="$maxValue"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$currentValue"/> </xsl:otherwise> </xsl:choose> </xsl:with-param> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> HTH: Andras Babos. > -----Original Message----- > From: birgit.zimmermann@xxxxxxxxxxxxxxx [mailto:birgit.zimmermann@fh- > rosenheim.de] > Sent: 2004. november 2. 21:39 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Get the maximum of a set of values > > Hello, > > I've got the following problem: > > I've got an index xml file that refers to some other xml files like that: ... > But my problem is, that I want to find the maximum of the attribute number > / the > variable vNumber!
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Get the maximum of a set , birgit . zimmermann | Thread | RE: [xsl] Get the maximum of a set , birgit . zimmermann |
Re: [xsl] complex positioning probl, Bruce D'Arcus | Date | RE: [xsl] Using normalize-space to , Michael Kay |
Month |