This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
string handling
- To: xsl-list at mulberrytech dot com
- Subject: string handling
- From: Jeff Lansing <jeff at dtai dot com>
- Date: Tue, 25 Apr 2000 17:49:37 -0700
- Reply-To: xsl-list at mulberrytech dot com
Here's an interesting asymetry in how you have to process strings with
XSLT/XPath:
<xsl:variable name="string" select="'hyperfitness'"/>
<xsl:variable name="unprefixed-string">
<xsl:if test="starts-with($string, 'hyper')">
<xsl:value-of select="substring-after($string, 'hyper')"/>
</xsl:if>
<xsl:if test="not(starts-with($string, 'hyper'))">
<xsl:value-of select="$string"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="unsuffixed-string"
select="substring-before(concat($string, 'ness'), 'ness')"/>
<xsl:value-of select="concat($unsuffixed-string, ' ',
$unprefixed-string)"/>
Of course the idea is not to get null variables when the input string
lacks the prefix/suffix.
Jeff
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list