+1 to the "3" in @id

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

Re: given @id="1.2.3" .... -1 || +1 to the "3" in @id

Subject: Re: given @id="1.2.3" .... -1 || +1 to the "3" in @id??
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 3 Jul 2001 09:43:30 +0100
substring after last jeni tennison
Hi Anthony,

> My main concern here is the syntax of getting the substring after
> the last '.' in a string: ie - if id="1.22.33" or "1.2.3", how do
> specify the character position of the last '.', since it will not
> always be the 4th or 5th character in the string.

I don't think anyone's shown you a recursive template to do this, so
here's one:

<xsl:template name="substring-after-last">
   <xsl:param name="string" />
   <xsl:param name="delimiter" select="'.'" />
   <xsl:choose>
      <xsl:when test="not(contains($string, $delimiter))">
         <xsl:value-of select="$string" />
      </xsl:when>
      <xsl:otherwise>
         <xsl:call-template name="substring-after-last">
            <xsl:with-param name="string"
               select="substring-after($string, $delimiter)" />
            <xsl:with-param name="delimiter"
                            select="$delimiter" />
         </xsl:call-template>
      </xsl:otherwise>
   </xsl:choose>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.