[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

max of ... (was your mail)

Subject: max of ... (was your mail)
From: Goetz Bock <bock@xxxxxxxxxxx>
Date: Thu, 8 Mar 2001 19:49:49 +0100
max goetz
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
  • [no subject]
    • Lindy Quick - Thu, 8 Mar 2001 13:26:42 -0500 (EST)
      • Goetz Bock - Thu, 8 Mar 2001 13:50:15 -0500 (EST) <=

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-2011 All Rights Reserved.