[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Get the maximum of a set of values
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: 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!
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|