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

Re: [xsl] Get the maximum of a set of values


Subject: Re: [xsl] Get the maximum of a set of values
From: "Werner, Wolfgang" <mail@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 03 Nov 2004 10:50:13 +0100

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Birgit,

this should do the Job

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
~  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
~  xmlns:exsl="http://exslt.org/common"
~  xmlns:math="http://exslt.org/math"
~  extension-element-prefixes="math exsl">

~  <xsl:template match='/'>
~    <xsl:variable name='numbers'>
~      <xsl:for-each select="index/entry">
~        <xsl:variable name="vXML" select='concat(xml,".xml")'/>
~        <NUMBER><xsl:value-of
select="document($vXML)/entry/item/@number" /></NUMBER>
~      </xsl:for-each>
~    </xsl:variable>

~ <xsl:value-of select='math:max(exsl:node-set($numbers)/NUMBER)'/>

~  </xsl:template>
</xsl:stylesheet>

If you are using an processor that supports exsl:node-set and math:max.
Many do. See http://exslt.org for details.

Greetings to Rosenheim. I used to live near it some time ago.

HTH,
Wolfgang

birgit.zimmermann@xxxxxxxxxxxxxxx wrote:
| Hello,
|
| I've got the following problem:
|
| I've got an index xml file that refers to some other xml files like that:
|
| <!-- index file -->
| <index>
| 	<entry><xml>X1</xml>...</entry>
| 	<entry><xml>X2</xml>...</entry>
| 	<entry><xml>X3</xml>...</entry>
| 	... <!-- and others -->
| </index>
|
| <!-- X1.xml -->
| <entry>
| 	<item number="3" />
| 	...
| </entry>
|
| <!-- X2.xml -->
| <entry>
| 	<item number="7" />
| 	...
| </entry>
|
| <!-- X3.xml -->
| <entry>
| 	<item number="2" />
| 	...
| </entry>
|
| The XSL file I have, belongs to the index file.
|
| In the xsl file I can get each value of the attribute number like this:
| <xsl:for-each select="index/entry">
| 	<xsl:variable name="vXML"><xsl:value-of select="xml"
/>.xml</xsl:variable>
| 	<xsl:variable name="vNumber"
select="document($vXML)/entry/item/@number" />
| </xsl:for-each>
|
| But my problem is, that I want to find the maximum of the attribute
number / the
| variable vNumber!
| This value should become a global variable.
|
| Does anyone has an idea?!
|
| Thanks
|
| BirgitZ
|
|
|
| -------------------------------------------------
| This mail sent through IMP: http://horde.org/imp/
|
|
|
|

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBiKnVqjaicDyx8o8RArfXAJkBW19hG5xssJjVa/ndkNonvOFfSQCfa1io
Y7s1Eb5wSYRRTqu/Uj8ON9E=
=LC0C
-----END PGP SIGNATURE-----


Current Thread
Keywords