This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
How can I sort values that have been calculated dynamically?
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] How can I sort values that have been calculated dynamically?
- From: Bryan Tulloch <b dot tulloch at solicitec dot com>
- Date: Fri, 13 Jul 2001 11:18:11 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hello,
This is connected to my earlier thread (Sorting a Nodeset contained within a
Variable), but as I haven't got that working I will try a more general
approach. Here goes:
My XML is a series of User elements structured as follows:
<User>
<User_Name></User_Name>
<Case_Code></Case_Code>
<Case_Title></Case_Title>
<Cost_Item>
<User_ID></User_ID>
<Job_Description></Job_Description>
<Charge_Rate></Charge_Rate>
<Item_Date></Item_Date>
<Item_Description></Item_Description>
<Time_Minutes></Time_Minutes>
<Cost></Cost>
</Cost_Item>
</User>
There may be a number of such entries with the same User_Name and a number
of those may have the same Case_Code and Case_Title.
The desired output:
I am outputting a table with a series of columns, each of which has a
heading which, when clicked, will sort the table data according to the
heading clicked.
Where I am at present:
Some of the columns contain data contained in the source XML (eg there are a
User_Name column and a Case_Code column); when these are clicked they are
sorting the data as required.
The problem:
Some of the columns contain data that is not directly in the source XML but
is computed from it (eg there is a column containing the total number of
unique Case_Code elements for each unique User_Name). I have a template
matching each unique User_Name, and within this the data is being output
into the table using this code:
<TH>
<xsl:variable name="ThisUser" select="." />
<xsl:value-of
select="count(//User[./User_Name=$ThisUser][not(Case_Code=preceding::Case_Co
de)])" />
</TH>
however, I have not been able to code the column heading so that it sorts
by this column when clicked.
Any suggestions as to how to go about this?
Bryan
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list