Re: [xsl] Max of...

Subject: Re: [xsl] Max of...
From: RSuiter@xxxxxxxxx
Date: Thu, 8 Mar 2001 13:13:42 -0600
Lindy Quick,

I composed this before I saw Goetz Beck's reply to your post, but I think
this is complementary to what he said, so I'm still going to send it

You wrote that you wanted to determine

   "for each the minimum and maximum value of each whole-request,
   and another-request.

   I have tried to determine the Whole Request maximum, using
   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>

   However, I return no data and my <td> is empty, can anyone tell me what
   I am doing wrong?"

The basic strategy for finding a maximum by sorting and taking the first
element is sound (so long as the number of rows doesn't get too large), and
has been discussed on the list before.  So why doesn't it work here?  You
don't really tell us enough about the context to be sure, but here are some
of the possibilities:

1.  There is no <td> in the snippet of xsl that you gave us, so your
variable "max" is going out of scope before you use it
(assuming that you wanted to use it in the template from which you called
2.  Remember that calling a named template does not change the current
node.  So the current node must be the parent of your rows (which is
<profile-table> in your example.  Otherwise the for-each will return
nothing at all.

If these don't put you on the right track, try posting a little more of
your xslt.

I hope this helps.

Rick Suiter

 XSL-List info and archive:

Current Thread