XSLT <xsl:sort> Element
The <xsl:sort> element is used to sort the output.
Where to put the Sort Information
To sort the output, simply add an <xsl:sort> element inside the <xsl:for-each> element in
the XSL file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<xsl:sort select="artist"/>
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
|
Note:
The select attribute indicates what XML element to sort on.
The result of the transformation above will look like this:
My CD Collection
| Title |
Artist |
| Romanza |
Andrea Bocelli |
| One night only |
Bee Gees |
| Empire Burlesque |
Bob Dylan |
| Hide your heart |
Bonnie Tyler |
| The very best of |
Cat Stevens |
| Greatest Hits |
Dolly Parton |
| Sylvias Mother |
Dr.Hook |
| Eros |
Eros Ramazzotti |
| Still got the blues |
Gary Moore |
| Unchain my heart |
Joe Cocker |
| Soulsville |
Jorn Hoel |
| For the good times |
Kenny Rogers |
| Midt om natten |
Kim Larsen |
| Pavarotti Gala Concert |
Luciano Pavarotti |
| 1999 Grammy Nominees |
Many |
| The dock of the bay |
Otis Redding |
| When a man loves a woman |
Percy Sledge |
| Maggie May |
Rod Stewart |
| Stop |
Sam Brown |
| Black angel |
Savage Rose |
| Picture book |
Simply Red |
| Bridge of Spies |
T`Pau |
| Red |
The Communards |
| Private Dancer |
Tina Turner |
| Tupelo Honey |
Van Morrison |
| Big Willie style |
Will Smith |
View the XML file,
View the XSL file, and
View the result
The Ektron Intranet
lets you do everything you need to do on your corporate intranet and everything you want to do... all with just one application.
What can you do with the Ektron Intranet? |

|
Navigate through content, documents, assets, colleagues and workgroups quickly and intuitively with enterprise search |

|
Communicate with friends and colleagues with forums, message boards and corporate blogging using the new Social Networking Platform |

|
Promote collaboration among coworkers in your organization through project workspaces where others can efficiently find information and work together |

|
Personalize your company profile by bookmarking and organizing favorite content, uploading assets, posting photos, blogging, and more |

|
Interact with features like tagging, flagging, wikis and ratings found in the Web 2.0 Toolbox |
 |
Author/edit content, manage navigation, menus, audit trails, workflow and approvals with the best in breed Content Management |
|
|
|
|
See why there are 20,000+ Ektron integrations worldwide. Request an
INSTANT DEMO or download a
FREE TRIAL today. |
|