[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: dynamic sorting

Subject: RE: dynamic sorting
From: Danny Guindi <Danny.Guindi@xxxxxxx>
Date: Sun, 4 Nov 2001 16:35:24 -0600
danny guindi
Thanks Max and Joerg for your replies.  I do, however, have a couple more
questions.

Max, the URLs you sent me show exactly what I want to do, but it doesn't
allow me to view the source, so I can see how JavaScript is called to
perform the sort.

Joerg, I still don't understand how parameters are passed between XML and
XSL?  Here is my simple test code, but I don't know how to make it sort.

XML
-----

<?xml version="1.0"?>

<root>
    <row>
        <name>test1</name>
        <age>20</age>
        <city>london</city>
        <country>great britain</country>
    </row>
    <row>
        <name>test2</name>
        <age>40</age>
        <city>new york</city>
        <country>united states</country>
    </row>
</root>

XSL
---

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="sort">name</xsl:param>

<xsl:template match="root">
	<table border='1'>
		<tr>
		<th>Name</th>
		<th>Age</th>
		<th>City</th>
		<th>Country</th>
		</tr>
	    <xsl:apply-templates select="row">
    	    <xsl:sort select="*[name() = $sort]"/>
    	</xsl:apply-templates>
	</table>
</xsl:template>

<xsl:template match="row">
		<tr>
    	<td><xsl:value-of select="name"/></td>
    	<td><xsl:value-of select="age"/></td>
    	<td><xsl:value-of select="city"/></td>
    	<td><xsl:value-of select="country"/></td>
    	</tr>
</xsl:template>

</xsl:stylesheet>

Thanks again,

Danny

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.