This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Page number ranges
- From: "Gustaf Liljegren" <gustaf dot liljegren at xml dot se>
- To: "XSL List" <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 22 Jan 2002 17:11:39 +0100
- Subject: [xsl] Page number ranges
- Reply-to: xsl-list at lists dot mulberrytech dot com
I'm working with an index in XSL FO. The source document looks like this:
<index>
<word page="12">cat</word>
<word page="58">dog</word>
<word page="23">giraffe</word>
...
</index>
The words are already sorted, and there are no duplicates (entries with both
the same attribute and element value). The code for printing page numbers
looks like this:
<xsl:for-each select="//word[.=current()]">
<xsl:sort select="@page" data-type="number"/>
<xsl:value-of select="@page"/>
<xsl:if test="not(position()=last())">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
This works fine, but I want to add a feature so that pages 12, 13, 14 is
written 12-14. How is that achieved?
Gustaf
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list