[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: sorting with param @attribute
At 2002-01-19 16:41 +0000, Ilyasov Jienbay wrote:
now with the same way passed param @id how can i have it sorted by @id and get By changing the axis that you used: <xsl:sort select="@*[name()=$sort]" /> If you have mutually exclusive element and attribute names, you could have: <xsl:sort select="@*[name()=$sort] | *[name()=$sort]" /> Then you could pass either generic identifier and only one of the above two sides of the union would have a non-empty value. I hope this helps. .............. Ken
t:\ftemp>type ilyasov.xsl <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:param name="sort"/> <xsl:output indent="yes"/> <xsl:template match="/"> <table> <xsl:for-each select="//item"> <xsl:sort select="@*[name()=$sort]|*[name()=$sort]" /> <tr> <td><xsl:value-of select="@id" /></td> <td><xsl:value-of select="title" /></td> </tr> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> t:\ftemp>saxon ilyasov.xml ilyasov.xsl sort=title <?xml version="1.0" encoding="utf-8"?> <table> <tr> <td>2</td> <td>3</td> </tr> <tr> <td>1</td> <td>4</td> </tr> <tr> <td>6</td> <td>5</td> </tr> </table> t:\ftemp>saxon ilyasov.xml ilyasov.xsl sort=id <?xml version="1.0" encoding="utf-8"?> <table> <tr> <td>1</td> <td>4</td> </tr> <tr> <td>2</td> <td>3</td> </tr> <tr> <td>6</td> <td>5</td> </tr> </table> t:\ftemp>rem Done! -- Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO - Feb 18-22, 2002 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) ISBN 0-13-065196-6 Definitive XSLT & XPath ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-07-1 Practical Formatting Using XSLFO XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed), articles, training(instructor-live,Internet-live,web/CD,licensed) Next public training: 02-02-11,12,14,15,18,21,03-04,05,06,08,11, - 04-08,09,10,12,05-14,15,06-04,07 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|