[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Top n values
Following is an example of how you can work with node-set()..
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan = "http://xml.apache.org/xalan" exclude-result-prefixes="xalan"> <xsl:template match="/"> <xsl:variable name="sorted-items"> <xsl:for-each select="/root/item"> <xsl:sort select="." order="descending" data-type="number"/> <xsl:copy-of select="."/> </xsl:for-each> </xsl:variable> <xsl:variable name="n-value" select="'3'"/> <xsl:for-each select="xalan:nodeset($sorted-items)/item[position()<= $n-value]"> <xsl:value-of select="."/><br/> </xsl:for-each> </xsl:template> </xsl:stylesheet> This works with XALAN.. From: Dan Diebolt <dandiebolt@xxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Top n values Date: Thu, 17 Oct 2002 12:30:04 -0700 (PDT) _________________________________________________________________ Get a speedy connection with MSN Broadband.? Join now! http://resourcecenter.msn.com/access/plans/freeactivation.asp 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
|