Description
The functx:trim function removes whitespace at the beginning and end of a string. Unlike the built-in fn:normalize-space function, it only removes leading and trailing whitespace, not whitespace in the middle of the value. Whitespace is defined as it is in XML, namely as space, tab, carriage return and line feed characters. If $arg is the empty sequence, it returns a zero-length string.
Arguments and Return TypeName | Type | Description |
$arg |
xs:string? |
the string to trim |
return value |
xs:string |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:trim
( $arg as xs:string? ) as xs:string {
replace(replace($arg,'\s+$',''),'^\s+','')
} ; |
ExamplesXQuery Example | Results |
---|
functx:trim(' xyz ') |
xyz |
functx:trim(' xyz') |
xyz |
functx:trim('x xyz ') |
x xyz |
See AlsoHistory |
Recommended Reading:
|