home contribute faq download

FunctX XQuery Functions

functx:chars

Converts a string to a sequence of characters

Google
Webxqueryfunctions.com

Description

The functx:chars function splits a string into individual characters and returns them as a sequence of strings of length 1 each.

Arguments and Return Type

NameTypeDescription
$arg xs:string? the string to split
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:chars 
  ( $arg as xs:string? )  as xs:string* {
       
   for $ch in string-to-codepoints($arg)
   return codepoints-to-string($ch)
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function chars 
  ( $arg as xs:string? )  as xs:string* {
       
   for $ch in fn:string-to-codepoints($arg)
   return fn:codepoints-to-string($ch)
 }

Examples

XQuery ExampleResults
functx:chars('abc')
('a', 'b', 'c')
functx:chars('a b c')
('a', ' ', 'b', ' ', 'c')

See Also

fn:tokenizeSplits a string based on a regular expression

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