String Processing

Steve Ball

$Id: string.html,v 1.1 2003/09/01 13:51:33 jkj Exp $


Table of Contents

str:to-upper - Make string uppercase
str:to-lower - Make string lowercase
str:capitalise - Capitalise string
str:to-camelcase - Convert a string to one camelcase word
str:substring-before-first - String extraction
str:substring-after-last - String extraction
str:substring-before-last - String extraction
str:subst - String substitution
str:count-substring - Count Substrings
str:substring-after-at - String extraction
str:insert-at - String insertion
str:backward - String reversal
str:character-first - Find first occurring character in a string
str:string-match - Match A String To A Pattern
str:generate-string - Create A Repeating Sequence of Characters







Name

str:to-camelcase — Convert a string to one camelcase word

Synopsis

<xsl:template name="str:to-camelcase">
<xsl:param name="text"/>
<xsl:param name="upper" select="true()"/>
<xsl:param name="string-with-only-spaces">
      <xsl:value-of select="translate($text,concat($xsltsl-str-ws,'/'),'     ')"/>
    </xsl:param>
<xsl:param name="before-space-removal">
      <xsl:variable name="firstword">
        <xsl:call-template name="str:substring-before-first">
          <xsl:with-param name="text" select="$string-with-only-spaces"/>
          <xsl:with-param name="chars" select="$xsltsl-str-ws"/>
        </xsl:call-template>
      </xsl:variable>
      <xsl:choose>
        <xsl:when test="$upper">
          <xsl:call-template name="str:to-upper">
            <xsl:with-param name="text" select="substring($firstword, 1, 1)"/>
          </xsl:call-template>
          <xsl:call-template name="str:to-lower">
            <xsl:with-param name="text" select="substring($firstword, 2)"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="str:to-lower">
            <xsl:with-param name="text" select="$firstword"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>

      <xsl:call-template name="str:capitalise">
        <xsl:with-param name="text">
          <xsl:value-of select="substring($string-with-only-spaces, string-length($firstword) + 2)"/>
        </xsl:with-param>
        <xsl:with-param name="all" select="true()"/>            
      </xsl:call-template>
    </xsl:param>
  ...
</xsl:template>