[xsl] last index of...

Subject: [xsl] last index of...
From: "Utah Ingersoll" <utah@xxxxxxxxxxxxxxx>
Date: Mon, 12 Nov 2001 12:57:21 +0300
Is there a function in XSLT which obtains the position of the last
occurrence of a string within another string?

Ive been trying to use creative combinations of string-length(),
substring(), substring-before() and substring-after() to get 'nnn' out
of 'aaa/bbb/ccc/~~~/nnn.zzz'.

specifically im trying to avoid this sort of ordeal....

 	<xsl:variable name="mainLength"
select="string-length(substring-before(name(.),'.'))"/>
 		<xsl:variable name="mainLessFrag"
select="substring(name(.),$mainLength+2)"/>
 	<xsl:variable name="secLength"
select="string-length(substring-before($mainLessFrag,'.'))"/>
 		<xsl:variable name="secLessFrag"
select="substring($mainLessFrag,$secLength+2)"/>
 	<xsl:variable name="main" select="substring-before(name(.),'.')"/>
 	<xsl:variable name="sec" select="substring-before($mainLessFrag,'.')"/>
 	<xsl:variable name="sub">
 		<xsl:choose>
 			<xsl:when test="$secLessFrag != 'xml'"><xsl:value-of
select="substring-before($secLessFrag,'.')"/></xsl:when>
			<xsl:otherwise><xsl:value-of select="$secLessFrag"/></xsl:otherwise>
		</xsl:choose>
	</xsl:variable>

which has never sat well with me!

thanks! utah oblio jared ingersoll


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


Current Thread