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]
Other format: [Raw text]

last index of...


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


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