[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: every 4th record increase counter
Abe Scott wrote:
I'm trying to create a field that will increase by 1 for every fourth record, ordered by \CommlVeh\ItemIdInfo\SystemId (We print 4 records per page) The records may be in random order and there may be missing id's in the list. Here is an XSLT 2.0 solution that performs two steps, sorts first, then groups: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:output indent="yes"/> <xsl:param name="n" as="xs:integer" select="4"/> <xsl:template match="root"> <xsl:variable name="sorted-vehicles"> <xsl:perform-sort select="CommlVeh"> <xsl:sort select="ItemIdInfo/SystemId" data-type="number"/> </xsl:perform-sort> </xsl:variable> <xsl:for-each-group select="$sorted-vehicles/CommlVeh" group-by="(position() - 1) idiv $n"> <xsl:for-each select="current-group()"> <Vehicle systemId="{ItemIdInfo/SystemId}" pageNum="{current-grouping-key() + 1}"/> </xsl:for-each> </xsl:for-each-group> </xsl:template> </xsl:stylesheet> -- Martin Honnen http://msmvps.com/blogs/martin_honnen/
|
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
|