Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL - Sorting Columns using <th> links

Status
Not open for further replies.

mischamcl

Programmer
Oct 26, 2001
1
GB
I've got a XML document and and XSL one that formats it into a table witht the following headers (and first row)
=
duration - cost - date - time - number
00:02:54 £1.80 10/02/01 14:54 07444748132
=

etc..

I would like to be able to click the headers of each row and have the page resort. I'm not able to use asp, or anything.. and currently am doing it all client side (as i'm very much a "new" user at xml/xslt.


here is a sample of my xml:
==============

<itemised_invoice no=&quot;2&quot;>
<sub_no no=&quot;383928&quot;>
<account_no>54555831</account_no>
<totalcost>105.33</totalcost>
<totalcalls>302</totalcalls>
<subphone>079895560</subphone>

<call_record id=&quot;1&quot;>
<time>10:45</time>
<date>10/08/2001</date>
<duration>01:20:45</duration>
<cost>£0.94</cost>
<bundled>no</bundled>
<ph_number>0788984432</ph_number>
</call_record>
...
...
...
================

and my xsl:
==============

<?xml version=&quot;1.0&quot;?>
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;<xsl:template match=&quot;/&quot;>

<html>
<body>
<table border=&quot;0&quot;>
<tr>
<th>Time</th>
<th>Date</th>
<th>Number</th>
<th>Cost</th>
<th>Bundled</th>
<th>Duration</th>
</tr>
<xsl:for-each select=&quot;itemised_invoice/sub_no/call_record&quot;>




<xsl:choose>
<xsl:when test=&quot;position() mod 2> 0&quot;>

<tr bgcolor=&quot;lightblue&quot;>
<td><xsl:value-of select=&quot;time&quot;/></td>
<td><xsl:value-of select=&quot;date&quot;/></td>
<td><xsl:value-of select=&quot;ph_number&quot;/></td>
<td><xsl:value-of select=&quot;cost&quot;/></td>
<td><xsl:value-of select=&quot;bundled&quot;/></td>
<td><xsl:value-of select=&quot;duration&quot;/></td>
</tr>

</xsl:when>

<xsl:eek:therwise>

<tr bgcolor=&quot;white&quot;>
<td><xsl:value-of select=&quot;time&quot;/></td>
<td><xsl:value-of select=&quot;date&quot;/></td>
<td><xsl:value-of select=&quot;ph_number&quot;/></td>
<td><xsl:value-of select=&quot;cost&quot;/></td>
<td><xsl:value-of select=&quot;bundled&quot;/></td>
<td><xsl:value-of select=&quot;duration&quot;/></td>

</tr>


</xsl:eek:therwise>
</xsl:choose>

</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


=================

any help would be apreciated.

Mischa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top