[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Page X of Y in user.footer.navigation
Thanks a lot! This is exactly what I needed. Diane Larin INRO ------------- Begin Included Message ------------- Well, I never know how much information to give because list participants have a wide range of experience with XSL. 8^) Here is a sample customization of 'user.footer.content'. The first three variables are global (not inside a template), so they are computed once when the stylesheet starts. <!-- Create the chunk hierarchy --> <xsl:variable name="mychunk.hierarchy"> <xsl:if test="function-available('exsl:node-set')"> <xsl:message>Computing chunks...</xsl:message> <xsl:apply-templates select="/*" mode="find.chunks"/> </xsl:if> </xsl:variable> <!-- Turn the chunk hierarchy into a node-set --> <xsl:variable name="mychunks" select="exsl:node-set($mychunk.hierarchy)//div"/> <!-- Get the total number of chunks --> <xsl:variable name="chunk.total" select="count($mychunks)"/> <!-- Add a line to the footer --> <xsl:template name="user.footer.content"> <!-- Get the id of the current chunk --> <xsl:variable name="genid" select="generate-id()"/> <!-- Get the position of the current chunk. You have to switch contexts using xsl:for-each to get the position within the node-set. --> <xsl:variable name="X"> <xsl:for-each select="$mychunks"> <xsl:if test="@id = $genid"> <xsl:value-of select="position()"/> </xsl:if> </xsl:for-each> </xsl:variable> <!-- Output the numbers --> <div class="nodecount"> <xsl:text>Node </xsl:text> <xsl:value-of select="$X"/> <xsl:text> of </xsl:text> <xsl:value-of select="$chunk.total"/> </div> </xsl:template> I originally thought iterating over all the chunks using xsl:for-each would slow things down, since it is done for each chunk. But my tests show it doesn't affect processing time much, even for a 400 chunk document. Bob Stayton Sagehill Enterprises DocBook Consulting bobs@sagehill.net ------------- End Included Message -------------
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]