home contribute faq download

FunctX XSLT Functions

functx:camel-case-to-words

Turns a camelCase string into space-separated words

Google
Webxsltfunctions.com

Description

The functx:camel-case-to-words function turns a camel-case string (one that uses upper-case letters to start new words, as in "thisIsACamelCaseTerm"), and turns them into a string of words using a space or other delimiter.

Arguments and Return Type

NameTypeDescription
$arg xs:string? the string to modify
$delim xs:string the delimiter for the words (e.g. a space)
return value xs:string

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:camel-case-to-words" as="xs:string"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="arg" as="xs:string?"/>
  <xsl:param name="delim" as="xs:string"/>

  <xsl:sequence select="
   concat(substring($arg,1,1),
             replace(substring($arg,2),'(\p{Lu})',
                        concat($delim, '$1')))
 "/>

</xsl:function>

Examples

XPath ExampleResults
functx:camel-case-to-words(
     'thisIsACamelCaseTerm',' ')
this Is A Camel Case Term
functx:camel-case-to-words(
     'thisIsACamelCaseTerm',',')
this,Is,A,Camel,Case,Term

See Also

functx:words-to-camel-caseTurns a string of words into camelCase

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery