Subject: RE: [xsl] Extracting string... From: "Paul Brown" <prb@xxxxxxxxxxxxx> Date: Fri, 12 Jan 2001 14:47:29 -0600 |
The answer is recursion: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template name="substring-after-last"> <xsl:param name="input" /> <xsl:param name="marker" /> <xsl:choose> <xsl:when test="contains($input,$marker)"> <xsl:call-template name="substring-after-last"> <xsl:with-param name="input" select="substring-after($input,$marker)" /> <xsl:with-param name="marker" select="$marker" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$input" /> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="FOO"><xsl:call-template name="substring-after-last"> <xsl:with-param name="input" select="'1.2.3.4.5.6.7'" /> <xsl:with-param name="marker" select="'.'" /> </xsl:call-template></xsl:template> </xsl:stylesheet> - Paul > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of > blackrock@xxxxxxx > Sent: Friday, January 12, 2001 10:18 AM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Extracting string... > > > Dear people, > > I read about the substring-after()-function, which can extract a substring > after the FIRST occurance of a specified string. > > My problem: Have you got an idea, how I can get the substring-after of a > string after the LAST occurance of a specified substring?? > > For example: I want the substring after the last ".". > > String: "A.B.C.0.1.1.hgk" > > The solution should return: "hgk" > > Any advice is greatly appreciated. > > > Thanks in advance. > > Yunus Karakaya > > > -- > Sent through GMX FreeMail - http://www.gmx.net > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Extracting string..., blackrock | Thread | [xsl] Newbie document() question, Edmund Mitchell |
[xsl] 
 Does not work, James Piva | Date | Re: [xsl] XML Update HOW TO?, Jeni Tennison |
Month |