[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

Subject: RE: Get the maximum of a set of values
From: "Babos, Andras" <ababos@xxxxxxxxxxxxx>
Date: Wed, 3 Nov 2004 14:10:23 +0100
maximum of a set
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 &lt; 1">
        <xsl:variable name="lastNumber" select="document (concat (string
(index/entry[position () = last ()]/xml), '.xml'))/entry/item/@number"/>

        <xsl:choose>
          <xsl:when test="$maxValue &gt; $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 &gt; $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!

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.