|
Subject:
|
Sorting element in xsl
|
|
Posted By:
|
Sakubar Sathik
|
Post Date:
|
4/6/2006 1:09:16 AM
|
Is it possible to sort two elements within a same for-each loop?
Sathik Khan
|
|
Reply By:
|
mhkay
|
Reply Date:
|
4/6/2006 3:45:59 AM
|
>Is it possible to sort two elements within a same for-each loop?
Sure, you can sort any number of elements in a for-each loop.
But that's so obvious, I must have misunderstood the question. Please be a bit more specific.
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
Sakubar Sathik
|
Reply Date:
|
4/6/2006 3:58:28 AM
|
I have two xml element let say user id and user name in an xml file. when transforming the xml file i want to sort these two elements.
Sathik Khan
|
|
Reply By:
|
mhkay
|
Reply Date:
|
4/6/2006 4:03:26 AM
|
I think it would be clearer if you showed a sample of your input and desired output.
Michael Kay http://www.saxonica.com/ Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|
Reply By:
|
Sakubar Sathik
|
Reply Date:
|
4/6/2006 4:10:49 AM
|
xml file ======== <?xml version="1.0" encoding="ISO-8859-1"?> <!-- Edited with XML Spy v2006 (http://www.altova.com) --> <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year> </cd> <cd> <title>Vande Madaram</title> <artist>AR Rahman</artist> <country>India</country> <company>Star</company> <price>9.90</price> <year>2002</year> </cd> <cd> <title>Greatest Hits</title> <artist>Dolly Parton</artist> <country>USA</country> <company>RCA</company> <price>9.90</price> <year>1982</year> </cd> </catalog>
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:output method='html' version='1.0' encoding='UTF-8' indent='yes'/> <xsl:template match="/">
<html> <body> <table> <tr> <table cellspacing="0" cellpadding="4" rules="all" bordercolor="#3366CC" border="1" id="dgReqList" style="background-color:White;border-color:#3366CC;border-width:1px;border-style:None;border-collapse:collapse;"> <xsl:variable name="count" select="0"/> <xsl:for-each select="catalog/cd"> <xsl:sort select="title"/> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="author"/></td> </tr> </xsl:for-each> </table></tr> </table> </body> </html> </xsl:template> </xsl:stylesheet>
Sathik Khan
|
|
Reply By:
|
Sakubar Sathik
|
Reply Date:
|
4/6/2006 4:23:53 AM
|
did u finished Michael
Regards, Sathik Khan
|