home contribute faq download

FunctX XQuery Functions

functx:right-trim

Trims trailing whitespace

Google
Webxqueryfunctions.com

Description

The functx:right-trim function removes all whitespace at the end of $arg. Whitespace is defined as it is in XML, namely space, tab, carriage return and line feed. If $arg is the empty sequence, it returns a zero-length string.

Arguments and Return Type

NameTypeDescription
$arg xs:string? the string to trim
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:right-trim 
  ( $arg as xs:string? )  as xs:string {
       
   replace($arg,'\s+$','')
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function right-trim 
  ( $arg as xs:string? )  as xs:string {
       
   fn:replace($arg,'\s+$','')
 }

Examples

XQuery ExampleResults
functx:right-trim('xyz   ')
xyz
functx:right-trim('  x   xyz  ')
  x   xyz
functx:right-trim('xyz')
xyz

See Also

functx:trimTrims leading and trailing whitespace
functx:left-trimTrims leading whitespace
fn:normalize-spaceNormalizes whitespace

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