[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Page number ranges
Thank you for your help Jeni. It gave some ideas on the logics involved, but as I embed this code into my stylesheet there are no page numbers at all in the output. Perhaps there is something in what I have written that conflicts with the code you suggested, so I post the whole template here to see if you or someone else can spot the problem. <xsl:template match="word"> <!-- I put your variable here in the top. --> <xsl:variable name="entries" select="word[. = current()]" /> <!-- This line is used because I don't want duplicate lines in the index for each match on the same word. --> <xsl:if test="not(.=preceding-sibling::word[1])"> <fo:block xsl:use-attribute-sets="serif-10 hyphenation" text-align-last="justify"> <!-- The word itself. --> <xsl:value-of select="."/> <!-- A space here, so that the line breaks before the leader if the numbers don't fit in the same line as the word. --> <xsl:text> </xsl:text> <fo:inline keep-together.within-line="always"> <fo:leader leader-pattern="dots"/> <xsl:for-each select="$entries"> <xsl:sort select="@page" data-type="number" /> <xsl:choose> <xsl:when test="$entries/@page = @page - 1"> <xsl:if test="not($entries/@page = @page + 1)"> <xsl:value-of select="concat('-', @page)" /> </xsl:if> </xsl:when> <xsl:otherwise> <xsl:if test="position() != 1">, </xsl:if> <xsl:value-of select="@page" /> </xsl:otherwise> </xsl:choose> </xsl:for-each> </fo:inline> </fo:block> </xsl:if> </xsl:template> "12-13" is good, but I wonder what happens if there are matches on page 12, 13, 14 and 15? Will they be written "12-14, 15" or "12-15"? Gustaf 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
|