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.
Thanks!
Kathryn
------Original Reply------------
Date: Wed, 18 Feb 2004 14:32:29 -0500
From: cknell(_at_)onebox(_dot_)com
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(_at_)onebox(_dot_)com - 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(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: Troubleshooting a sort
Hello,
I'm trying to sort an XML file--here's a representative record:
<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>
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!
Kathryn
<TABLE border="0" width="92%" style="font-size: 10pt" cellspacing="1"
cellpadding="1">
<tr>
<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><b>Idea</b></th>
<th><a href="javascript:View5()" style="color:#ffffff"><b>Status</b></a></th>
</tr>
<xsl:for-each select="//SAVEIdeas/SAVEIdea">
<xsl:sort select="*[name()=$param1]"/>
<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:value-of select="status_history/status[last()]"/>
</td>
</tr>
</xsl:for-each>
</TABLE>
**********************************************************
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