I had to print the last value of a dynamic tilde (~) delimited string in the HTML (email content). The style sheets are done in XSL. This is how i made it work:
I defined a template:
<xsl:template name="returnLastValueofString"> <xsl:param name="inputString"/> <xsl:choose> <xsl:when test="substring-after($inputString,'~')"> <xsl:call-template name="returnLastValueofString"> <xsl:with-param name="inputString" select="substring-after($inputString,'~')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$inputString"/> </xsl:otherwise> </xsl:choose> </xsl:template> This is how i called the value: <xsl:call-template name="returnLastValueofString"> <xsl:with-param name="inputString" select="$OriginalStringAttribute"/> </xsl:call-template>
Advertisement






the template you have defined, is better in case you want to iterate upon each value of your delimited string, but in your use case you want to retrieve the last value from the delimiter.
So to save your processing time, you should write a reg ex which begins from “the end” of the string, goes back in the direction and search out for the first occurrence of your delimiter. This way you can have ur index of the last value of the delimited string directly and saving lot of un-necessary iterations.
That works too. Thanks much.
I was sure that the string that i have is very short mostly. I haven’t looked in that perspective.