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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using XSL and XML to sort

Status
Not open for further replies.

flattley

Technical User
Jul 6, 2007
2
GB
I am trying to sort a list 3 different ways. E.G Title, Cert, Length.

I have tried to add the xsl ahref and xsl sort attributes to this. All I get is an error saying that I can't use sort.

Is there anyway that I can make a clickable link for title, cert and length and that when clicked they will sort the data in the table?

Any help would be much appreciated.

Chris
 
Chris,

Welcome to Tek-Tips.

The answer to your question is, "Probably yes."

In order to be more helpful, especially to diagnose what might be causing the error, it would be helpful to see the XSL and some sample XML input.

Also, are we to presume you wish to accomplish this in JavaScript?

Tom Morrison
 
Thanks for the quick reply.

I am not getting the error since I moved the xsl:sort, but I am not getting any output.

Output should be - Sort by: Length (This should be a clickable link to sort by length of movie)


XML code:

<dvd>
<title><![CDATA[Lock, Stock & Two Smoking Barrels]]></title>
<link><![CDATA[]]></link>
<cert>18.gif</cert>
<cert1>Eighteen (18)</cert1>
<barcode>044005939026</barcode>
<releaseYear>1998</releaseYear>
<runTime>107 mins</runTime>
<genre>Comedy</genre>
<genre1>Thriller</genre1>
<cert2>18</cert2>
</dvd>

XSL Code:

<tr><td class="sort">Sort by: <xsl:for-each select="channel"><xsl:value-of select="channel/runTime"/><xsl:element name="a"><xsl:attribute name="href">Length</xsl:attribute></xsl:element></xsl:for-each><p/></td></tr>

I am not sure whether I would have to use JS for this or not.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top