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]

string handling


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

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