This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Max value from a table
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: Re: [xsl] Max value from a table
- From: Jörg Heinicke <joerg dot heinicke at gmx dot de>
- Date: Tue, 23 Oct 2001 23:46:35 +0200
- References: <20011023211051.13166.qmail@mail.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:variable name="max">
<xsl:for-each select="/table/row/col">
<xsl:sort select="text()" data-type="number" order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="text()"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="col">
<xsl:copy>
<xsl:value-of select="text() div $max"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Joerg
----- Original Message -----
From: "Mark Harburg" <mharburg@rome.com>
To: <XSL-List@lists.mulberrytech.com>
Sent: Tuesday, October 23, 2001 11:10 PM
Subject: [xsl] Max value from a table
> I need to find the largest value from a table and use that in calculating
percentage values in my target XML document.
>
> eg.
> ---- FROM ------
> <?xml version="1.0"?>
> <table>
> <row><col>25</col><col>7</col></row>
> <row><col>1</col><col>100</col></row>
> </table>
>
> -- 100 is the largest value in the table - now used to calculate each new
cell as x / 100.
>
> ---- TO ------
> <?xml version="1.0"?>
> <table>
> <row><col>.25</col><col>.07</col></row>
> <row><col>.01</col><col>1</col></row>
> </table>
>
>
> Any ideas?
> Thanks!
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list