[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Extracting string...
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: 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|