[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 2002-01-19 16:41 +0000, Ilyasov Jienbay wrote:
By changing the axis that you used:
<xsl:sort select="@*[name()=$sort]" />
If you have mutually exclusive element and attribute names, you could have:
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
<xsl:param name="sort"/>
<xsl:output indent="yes"/>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] sorting with param @attribute
Subject: Re: [xsl] sorting with param @attribute From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 19 Jan 2002 12:59:40 -0500 |
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.xml <?xml version="1.0" encoding="utf-8"?> <items> <item id="6"> <title>5</title> </item> <item id="2"> <title>3</title> </item> <item id="1"> <title>4</title> </item> </items>
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] sorting with param @attribute, Ilyasov Jienbay | Thread | [xsl] output xhtml with html style , Thomas Winkler |
[xsl] sorting with param @attribute, Ilyasov Jienbay | Date | Re: [xsl] NMTOKENS enumeration?, cutlass |
Month |