xsl-list
[Top] [All Lists]

RE: Troubleshooting a sort

2004-02-20 12:02:26
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:

<SAVEIdea>
      <SAVE_ID>25</SAVE_ID>
      <date_submitted>01/14/2004</date_submitted>
      <employee>Kathryn Grant</employee>
      <department>OPE</department>
      <idea>Buy faster printers.</idea>
      <status_history>
         <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>
      </status_history>
 </SAVEIdea>

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!

Kathryn

<?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="/">

<TABLE>

<tr>
<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>
</tr>


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

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

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

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

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

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

</tr>
</xsl:for-each>
</TABLE>    
</xsl:template>

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

</xsl:stylesheet>


**********************************************************
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



<Prev in Thread] Current Thread [Next in Thread>