|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Output sorted XHTML table for a subset of elements
Steven Davies wrote:
I know my sample data was a bit small but there are a lot more nodes in my actual data set. Here's an attempt at a better example: Here is an XSLT 1.0 stylesheet making use of exslt:node-set: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" exclude-result-prefixes="exsl" version="1.0"> <xsl:output method="html" indent="yes"/> <xsl:param name="cols" select="5"/> <xsl:param name="min-lines" select="25"/> <xsl:template match="/">
<html>
<head>
<title>Example</title>
</head>
<body>
<xsl:apply-templates select="users"/>
</body>
</html>
</xsl:template><xsl:template match="users"> <xsl:variable name="sorted-users-rtf"> <data> <xsl:for-each select="user[lines > $min-lines]"> <xsl:sort select="lines" data-type="number" order="descending"/> <xsl:copy-of select="."/> </xsl:for-each> </data> </xsl:variable> <xsl:variable name="sorted-users" select="exsl:node-set($sorted-users-rtf)/data/user"/> <table> <tbody> <xsl:apply-templates select="$sorted-users[position() mod $cols = 1]" mode="row"/> </tbody> </table> </xsl:template> <xsl:template match="user" mode="row"> <tr> <xsl:apply-templates select=". | following-sibling::user[position() < $cols]" mode="cell"/> </tr> </xsl:template> <xsl:template match="user" mode="cell">
<td>
<xsl:value-of select="concat(@name, ' (', lines, ')')"/>
</td>
</xsl:template></xsl:stylesheet> I think libXSLT supports exsl:node-set. -- Martin Honnen http://JavaScript.FAQTs.com/
|
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
|

Cart








