$Id: string.html,v 1.11 2004/10/10 06:18:57 balls Exp $
Copyright © 2002, 2001 Steve Ball
Table of Contents
str:to-upper — Make string uppercase
<xsl:template name="str:to-upper"><xsl:param name="text"/><xsl:param name="modified-text"> <xsl:call-template name="str:subst"> <xsl:with-param name="text"> <xsl:value-of select="$text"/> </xsl:with-param> <xsl:with-param name="replace"> <xsl:text>ß</xsl:text> </xsl:with-param> <xsl:with-param name="with"> <xsl:text>S</xsl:text> <xsl:text>S</xsl:text> </xsl:with-param> </xsl:call-template> </xsl:param> ...</xsl:template>
str:to-lower — Make string lowercase
<xsl:template name="str:to-lower"><xsl:param name="text"/> ...</xsl:template>
str:capitalise — Capitalise string
<xsl:template name="str:capitalise"><xsl:param name="text"/><xsl:param name="all" select="true()"/> ...</xsl:template>
Converts first character of string to an uppercase letter. All remaining characters are converted to lowercase.
str:to-camelcase — Convert a string to one camelcase word
<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>
Converts a string to one lowerCamelCase or UpperCamelCase word, depending on the setting of the "upper" parameter. UpperCamelCase is also called MixedCase while lowerCamelCase is also called just camelCase. The template removes any spaces, tabs and slashes, but doesn't deal with other punctuation. It's purpose is to convert strings like "hollow timber flush door" to a term suitable as identifier or XML tag like "HollowTimberFlushDoor".
str:substring-before-first — String extraction
<xsl:template name="str:substring-before-first"><xsl:param name="text"/><xsl:param name="chars"/> ...</xsl:template>
str:substring-after-last — String extraction
<xsl:template name="str:substring-after-last"><xsl:param name="text"/><xsl:param name="chars"/> ...</xsl:template>
Extracts the portion of string 'text' which occurs after the last of the character in string 'chars'.
str:substring-before-last — String extraction
<xsl:template name="str:substring-before-last"><xsl:param name="text"/><xsl:param name="chars"/> ...</xsl:template>
Extracts the portion of string 'text' which occurs before the first character of the last occurance of string 'chars'.
str:subst — String substitution
<xsl:template name="str:subst"><xsl:param name="text"/><xsl:param name="replace"/><xsl:param name="with"/><xsl:param name="disable-output-escaping">no</xsl:param> ...</xsl:template>
The string upon which to perform substitution.
The string to substitute.
The string to be substituted.
A value of yes indicates that the result should have output escaping disabled. Any other value allows normal escaping of text values. The default is to enable output escaping.
str:count-substring — Count Substrings
<xsl:template name="str:count-substring"><xsl:param name="text"/><xsl:param name="chars"/> ...</xsl:template>
Counts the number of times a substring occurs in a string. This can also counts the number of times a character occurs in a string, since a character is simply a string of length 1.
str:substring-after-at — String extraction
<xsl:template name="str:substring-after-at"><xsl:param name="text"/><xsl:param name="chars"/><xsl:param name="position"/><xsl:param name="all" select="false()"/> ...</xsl:template>
str:substring-before-at — String extraction
<xsl:template name="str:substring-before-at"><xsl:param name="text"/><xsl:param name="chars"/><xsl:param name="position"/> ...</xsl:template>
str:insert-at — String insertion
<xsl:template name="str:insert-at"><xsl:param name="text"/><xsl:param name="position"/><xsl:param name="chars"/> ...</xsl:template>
str:backward — String reversal
<xsl:template name="str:backward"><xsl:param name="text"/> ...</xsl:template>
str:justify — Format a string
<xsl:template name="str:justify"><xsl:param name="text"/><xsl:param name="max" select=""80""/><xsl:param name="indent" select=""0""/><xsl:param name="justify" select=""left""/> ...</xsl:template>
str:character-first — Find first occurring character in a string
<xsl:template name="str:character-first"><xsl:param name="text"/><xsl:param name="chars"/> ...</xsl:template>
str:string-match — Match A String To A Pattern
<xsl:template name="str:string-match"><xsl:param name="text"/><xsl:param name="pattern"/> ...</xsl:template>
Example 2. Match Pattern
<xsl:call-template name="str:string-match"> <xsl:with-param name="text" select="$mytext"/> <xsl:with-param name="pattern" select="'abc*def?g'"/> </xsl:call-template>