|
Subject: Re: [xsl] collapsing number ranges From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Fri, 27 Aug 2004 10:21:57 +0100 |
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/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] collapsing number ranges, Michael Kay | Thread | Re: [xsl] collapsing number ranges, J-P S |
| RE: [xsl] collapsing number ranges, Jarno.Elovirta | Date | Re: [xsl] collapsing number ranges, J-P S |
| Month |