[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Grouping consecutive page numbers for index (xslt
On 21/08/2013 14:49, Kevin Bird wrote:
Hello,
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template match="pages"> <xsl:apply-templates select="page[1]"> <xsl:with-param name="first" select="page[1]"/> <xsl:with-param name="last" select="page[1]"/> </xsl:apply-templates> </xsl:template> <xsl:template match="page"> <xsl:param name="first"/> <xsl:param name="last"/> <xsl:choose> <xsl:when test="following-sibling::page[1][.=$last+1]"> <xsl:apply-templates select="following-sibling::page[1][.=$last+1]"> <xsl:with-param name="first" select="$first"/> <xsl:with-param name="last" select="$last+1"/> </xsl:apply-templates> </xsl:when> <xsl:when test="following-sibling::page"> <page><xsl:if test="$first!=$last"><xsl:value-of select="$first"/>-</xsl:if><xsl:value-of select="$last"/></page> <xsl:apply-templates select="following-sibling::page[1]"> <xsl:with-param name="first" select="following-sibling::page[1]"/> <xsl:with-param name="last" select="following-sibling::page[1]"/> </xsl:apply-templates> </xsl:when> <xsl:otherwise> <page><xsl:if test="$first!=$last"><xsl:value-of select="$first"/>-</xsl:if><xsl:value-of select="$last"/></page> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> David
This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
|
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
|