This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Applying two transformations consecutively


Hi Rechell,

> Thanks for your suggestions. One thing that may complicate things is
> that I do my sorting based on parameters that the user enters at
> run-time that specify the desired column to sort on, whether the
> column should be sorted as text or as a number and whether the sort
> is ascending or descending. I tried to incorporate your suggestions,
> but failed. Can you help me adjust my stylesheet so that I can get
> the TOTAL to stay on the bottom (and perhaps to keep the zero on the
> top until Apache fixes their bug)?

It sounds as if you always want the last row to appear at the bottom
of your table. In that case it's probably easier to have the
xsl:apply-templates work on all the rows save the last, with that
being sorted according to your parameters, and then output the result
of applying templates to the last row:

  <xsl:apply-templates select="row[position() != last()]">
     <xsl:sort select="*[name() = $sortcolumn]"
               data-type="{$sort_type}" order="{$sortorder}" />
  </xsl:apply-templates>
  <xsl:apply-templates select="row[last()]" />

Otherwise, I think that it works out OK to just always sort on that
particular column, first boolean on whether it's a number, second by
number and finally by text. Note that the first sort is the other way
round from how I did it before, to get the text to sort after the
numbers rather than the other way around, but that this is fixed
rather than using the $sortorder parameter so that the TOTAL row is
always after the numerical ones, but this means that the sort order
for the rows might not be exactly what you want:

  <xsl:apply-templates select="row">
     <xsl:sort select="number(*[name() = $sortcolumn]) or
                       number(*[name() = $sortcolumn]) = 0"
               order="descending" />
     <xsl:sort select="*[name() = $sortcolumn]"
               data-type="number" order="{$sortorder}" />
     <xsl:sort select="*[name() = $sortcolumn]"
               data-type="text" order="{$sortorder}" />
  </xsl:apply-templates>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]