This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
max of ... (was your mail)
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] max of ... (was your mail)
- From: Goetz Bock <bock at blacknet dot de>
- Date: Thu, 8 Mar 2001 19:49:49 +0100
- References: <3A9244590000C020@mail.direxus.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
On Thu, Mar 08 '01 at 12:26, Lindy Quick wrote:
> <profile-table>
> <row>
> <whole-request>123</whole-request>
> <sub-request>23</sub-request>
> <another-request>100</another-request>
> </row>
> [ ... ]
> </profile-table>
>
> I have tried to determine the Whole Request maximum, using xsl:call-template
> to put it in the proper <td> of my table
>
> <xsl:template name="WholeRequestMax">
> <xsl:variable name="max">
> <xsl:for-each select="row/whole-request">
> <xsl:sort data-type="number" order="descending"/>
> <xsl:if test="position()=1">
> <xsl:value-of select="."/></xsl:if>
> </xsl:for-each>
> </xsl:variable>
> </xsl:template>
>
> However, I return no data and my <td> is empty, can anyone tell me what
> I am doing wrong.
You don't produce any output, remove the <xsl:variable> ...
</xsl:variable>, and your template will produce your desired output.
<xsl:template name="WholeRequestMax">
<xsl:for-each select="row/whole-request">
<xsl:sort data-type="number" order="descending"/>
<xsl:if test="position()=1">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:template>
I don't think this i to effective, though. You walk through all nodes
while you only need the first one. But assuming the <xsl:sort> takes
O(n log(n)) the additional O(n) to test all sorted nodes does not hurt.
I tried to think up something better using another called template bat
failed :-( ... some times later i will have time again to think about how
to otimize XSL-Ts.
Cu,
Goetz.
PGP signature