[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: collapsing number ranges

Subject: Re: collapsing number ranges
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 27 Aug 2004 10:21:57 +0100
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/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.