[xsl] RE: Troubleshooting a sort

Subject: [xsl] RE: Troubleshooting a sort
From: "Grant, Kathryn --- Sr. Technical Writer --- WGO" <Kathryn.Grant@xxxxxxxxxxxxxxxxx>
Date: Fri, 20 Feb 2004 11:02:26 -0800
Hi David,

Thanks for your reply. I'm sure it's due to my inexperience that it's still not working. Some kind of sort is being performed by the code you suggested (in other words, the elements do reorder), but I can't see a pattern to it.

For reference, here's sample XML:

      <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 status_history may be one or more status elements. 

Summary if you're just joining us :) I need the following XSL to sort on the SAVE_ID, date_submitted, employee, department, and *last* status element inside status_history. All sorts are working fine EXCEPT the sort on the last status element.

I'm going to include the whole XSL file below because I suspect the problem lies there. Thanks in advance for any ideas!


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

<xsl:param name="param1"/>

<xsl:output method="html"/>
<xsl:template match="/">


<th width="7%"><a href="javascript:View1()"><b>SAVE ID</b></a></th>
<th width="14%"><a href="javascript:View2()"><b>Date Submitted</b></a></th>
<th width="17%"><a href="javascript:View3()"><b>Submitted by</b></a><br/><a href="javascript:View4()"><b>(Department)</b></a></th>
<th width="29%"><b>Idea</b></th>
<th width="33%"><a href="javascript:View6()"><b>Status</b></a></th>

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

  <td style="font-size:8pt" valign="top">
     <a href='javascript:loadnew2({SAVE_ID})'><xsl:value-of select="SAVE_ID"/></a>

  <td style="font-size:8pt" valign="top">
    <xsl:value-of select="date_submitted"/>

  <td style="font-size:8pt" valign="top">
    <xsl:value-of select="employee"/> (<xsl:value-of select="department"/>)

  <td style="font-size:8pt" valign="top">
        <xsl:value-of select="idea"/>

  <td style="font-size:8pt" valign="top">
    <xsl:apply-templates select="status_history"/>


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


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