[xsl] Troubleshooting a sort

Subject: [xsl] Troubleshooting a sort
From: "Grant, Kathryn --- Sr. Technical Writer --- WGO" <Kathryn.Grant@xxxxxxxxxxxxxxxxx>
Date: Thu, 19 Feb 2004 16:24:42 -0800

Thanks for your ideas! They didn't work, which probably means I wasn't clear enough. Let me try again :)

Here's a representative XML record:

      <employee>Kathryn Grant</employee>
      <idea>Buy faster printers.</idea>
         <status timestamp="1/20/04, 4:33:13 PM" userID="GRANT01">Submitted for supervisor review</status>
         <status timestamp="1/25/04, 9:21:45 AM" userID="GRANT01">Submitted for CFO review</status>
         <status timestamp="1/29/04, 6:12:22 PM" userID="GRANT01">Approved</status>

Each SAVEIdea has one status_history element, and within the status_history may be one or more status elements. 

A JavaScript on my web page passes the to-be-sorted tagname as a parameter (e.g. var pass1 = 'date_submitted'), which my XSL file handles as follows:

<xsl:for-each select="//SAVEIdeas/SAVEIdea">
<xsl:sort select="*[name()=$param1]"/>

Then, an HTML table displays the sorted results:
 <td style="font-size:8pt" valign="top">
    <xsl:value-of select="date_submitted"/>

Usually, I'm sorting on a child of the root element (SAVE_ID, date_submitted, etc.) These sorts are all working fine. But I also need to sort on the *last* status element. Status is not a child of the root, but a child of status_history. Is that the problem? Do I need to have something conditional for the sort statement? I welcome any additional suggestions!

Many thanks--



Date: Thu, 19 Feb 2004 20:32:54 +0100
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Subject: RE: [xsl] FW: Troubleshooting a sort

> -----Original Message-----
> From: Grant, Kathryn
> If anyone has any other ideas, I'd welcome them.


Sorry, ignore my other post... or at least study it very carefully, and
you'll notice that I was too quick :) Can't sort status_history elements, as
there's only one per SAVEIdea, not?

Basic idea will work in your situation though...
Only should be more like

  <td ...>
    <xsl:apply-templates select="status_history" />

<xsl:template match="status_history">
  <xsl:value-of select="status[last()]

if the status elements are always sorted ascending.



This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.

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

Current Thread