home contribute faq download

FunctX XQuery Functions

functx:words-to-camel-case

Turns a string of words into camelCase

Google
Webxqueryfunctions.com

Description

The functx:words-to-camel-case function turns a string composed of multiple words (e.g. 'this is a term") into a camel-case value (one that uses upper-case letters to start new words, e.g. "thisIsATerm".

Arguments and Return Type

NameTypeDescription
$arg xs:string? the string to modify
return value xs:string

XQuery Function Declaration

See XSLT definition.
XQuery Syntax for July 2004 - January 2007 (1.0):
declare namespace functx = "http://www.functx.com"; 
declare function functx:words-to-camel-case 
  ( $arg as xs:string? )  as xs:string {
       
     string-join((tokenize($arg,'\s+')[1],
       for $word in tokenize($arg,'\s+')[position() > 1]
       return functx:capitalize-first($word))
      ,'')
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function words-to-camel-case 
  ( $arg as xs:string? )  as xs:string {
       
     fn:string-join((fn:tokenize($arg,'\s+')[1],
       for $word in fn:tokenize($arg,'\s+')[fn:position() > 1]
       return functx:capitalize-first($word))
      ,'')
 }

Examples

XQuery ExampleResults
functx:words-to-camel-case('this Is A Term')
thisIsATerm
functx:words-to-camel-case(
   'This is a      term')
ThisIsATerm

Depends On

functx:capitalize-firstCapitalizes the first character of a string

See Also

functx:camel-case-to-wordsTurns a camelCase string into space-separated words

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Need XQuery Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley