[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] max of ... (was your mail)
Subject: [xsl] max of ... (was your mail) From: Goetz Bock <bock@xxxxxxxxxxx> Date: Thu, 8 Mar 2001 19:49:49 +0100 |
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.
Attachment:
pgp00000.pgp
Description: PGP signature
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[no subject], Lindy Quick | Thread | Re: [xsl] Max of..., RSuiter |
[xsl] Substituting value in XML Att, Raj Avula | Date | Re: [xsl] Substituting value in XML, Goetz Bock |
Month |