[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: collapsing number ranges
Hi Bruce, > Is there some easy way -- in XSLT 2.0 -- to handle in a general way > collapsing number ranges like: > > 23-24 => 23-4 > 333-334 => 333-34 > 7777-7778 => 7777-78 > > The source will be like: > > <biblioref linkend="one" units="page" begin="23" end="24" /> Taking a guess at the algorithm, what about: <xsl:value-of select="@begin" /> <xsl:text>-</xsl:text> <xsl:choose> <xsl:when test="string-length(@begin) = 1"> <xsl:value-of select="@end" /> </xsl:when> <xsl:when test="string-length(@begin) = 2"> <xsl:value-of select="substring(@end, 2, 1)" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="substring(@end, last() - 1)" /> </xsl:otherwise> </xsl:choose> If that's not what you're after, show us the XML of some more examples and try to put the algorithm that you want into English or pseudo-code. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
|
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
|