home contribute faq download

FunctX XQuery Functions

functx:capitalize-first

Capitalizes the first character of a string

Google
Webxqueryfunctions.com

Description

The functx:capitalize-first function capitalizes the first character of $arg. If the first character is not a lowercase letter, $arg is left unchanged. It capitalizes only the first character of the entire string, not the first letter of every word.

Arguments and Return Type

NameTypeDescription
$arg xs:string? the word or phrase to capitalize
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:capitalize-first 
  ( $arg as xs:string? )  as xs:string? {
       
   concat(upper-case(substring($arg,1,1)),
             substring($arg,2))
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function capitalize-first 
  ( $arg as xs:string? )  as xs:string? {
       
   fn:concat(fn:upper-case(fn:substring($arg,1,1)),
             fn:substring($arg,2))
 }

Examples

XQuery ExampleResults
functx:capitalize-first('hello')
Hello
functx:capitalize-first('hello world')
Hello world
functx:capitalize-first('Hello world')
Hello world

See Also

fn:upper-caseConverts to upper case

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