[xsl] FW: Troubleshooting a sort

Subject: [xsl] FW: Troubleshooting a sort
From: "Grant, Kathryn --- Sr. Technical Writer --- WGO" <Kathryn.Grant@xxxxxxxxxxxxxxxxx>
Date: Thu, 19 Feb 2004 09:50:45 -0800
Hi Charles,

Thanks for the idea--unfortunately, it didn't work. The first four sorts still worked fine, but this time the Status sort simply repeated the status of the first record for all the records. I guess this is one of those //-related bugs you were talking about :)

If anyone has any other ideas, I'd welcome them.



------Original Reply------------
Date: Wed, 18 Feb 2004 14:32:29 -0500
From: cknell@xxxxxxxxxx
Subject: RE: [xsl] Troubleshooting a sort

Untested but reasonable idea:

Replace this:
<xsl:sort select="*[name()=$param1]"/>

With this:
<xsl:sort select="descendant::*[name()=$param1]"/>

By the way, where are you applying this template that requires you to use the "//" to preface the XPath. Double slashes are often a poor XSLT programming practice resulting in unnecessary tree traversal and could lead to performance problems and incorrect and hard-to-diagnose bugs. Use them only when there is no other reasonable option.

- -- 
Charles Knell
cknell@xxxxxxxxxx - email

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

-----Original Message-----
From: Grant, Kathryn --- Sr. Technical Writer --- WGO 
Sent: Wednesday, February 18, 2004 11:12 AM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: Troubleshooting a sort


I'm trying to sort an XML file--here's a representative 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>

The name of the tag by which I want to sort is passed as a parameter to the XSL file from a web page using javascript. Below is the XSL, and the sort works for every column except the Status column (last column). 

As you can see in the XML file, the status tag is a level deeper than the other tags I'm sorting on. In addition, I'm pulling the last of all the status tag. So how can I make the status sort work?

Thanks in advance!


<TABLE border="0" width="92%" style="font-size: 10pt" cellspacing="1" cellpadding="1">

<th><a href="javascript:View1()"><b>SAVE ID</b></a></th>
<th><a href="javascript:View2()"><b>Date Submitted</b></a></th>
<th><a href="javascript:View3()"><b>Submitted by</b></a><br/>
	<a href="javascript:View4()"><b>(Department)</b></a></th>
<th><a href="javascript:View5()" style="color:#ffffff"><b>Status</b></a></th>

<xsl:for-each select="//SAVEIdeas/SAVEIdea">
    <xsl:sort select="*[name()=$param1]"/>
  <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:value-of select="status_history/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