This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]