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 |
XSLT Function DeclarationSee XQuery definition. | <xsl:function name="functx:trim" as="xs:string"
xmlns:functx="http://www.functx.com">
<xsl:param name="arg" as="xs:string?"/>
<xsl:sequence select="
replace(replace($arg,'\s+$',''),'^\s+','')
"/>
</xsl:function>
|
ExamplesXPath Example | Results |
---|
functx:trim(' xyz ') |
xyz |
functx:trim(' xyz') |
xyz |
functx:trim('x xyz ') |
x xyz |
See AlsoHistory |
Recommended Reading:
|