Sort Column In Table (ascending) Using attributes

A

AwanJohnie

I have an XML doc and successfully transformed into a table using XSL.
The Challenge is how to sort the information by columns. I am writting
diffrent XSL for the diffrent sorts (i.e per column) but I can't just
get the basic one to work. I get no errors but the data is not sorted.
Please help.

1. To order by Title===@name
2. To Order by Author ===../attribute[@attid='5']
3. To order by Date === .../attribute[@attid='3']

XSL

<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="live" />
</body>
</html>
</xsl:template>

<xsl:template match="live">

<table >
<tr >
<th>Title</th>
<th>Author</th>
<th>Date</th>
</tr>
<xsl:for-each select="llnode">

<xsl:sort select = "./@name" order="descending"/>

<xsl:apply-templates select="llnode" />
</xsl:for-each>

</table>
</xsl:template>

<xsl:template match="llnode">

<tr>

<td width="44%"> <A>
<xsl:attribute name="HREF">
http://www.whateverurl.org=<xsl:value-of
select="@id"/>&amp;objAction=open </xsl:attribute>
<xsl:value-of select="@name"/> </A> </td>
<td ><xsl:value-of select="category/attributeset/attribute
[@attid='5']"/></td>

<td>
<xsl:value-of select="substring-before(category/attributeset/attribute[@attid='3'],'T')"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
 
J

Joris Gillis

<xsl:sort select = "./@name" order="descending"/>

<xsl:apply-templates select="llnode" />
</xsl:for-each>

Why do you use the for-each?
I think this should work.

<xsl:apply-templates select="llnode">
<xsl:sort select = "./@name" order="descending"/>
</xsl:apply-templates>



Joris Gillis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top