Description
The functx:substring-before-if-contains function performs substring-before, returning the entire string if it does not contain the delimiter. It differs from the built-in fn:substring-before function, which returns a zero-length string if the delimiter is not found.
Arguments and Return TypeName | Type | Description |
$arg |
xs:string? |
the string to substring |
$delim |
xs:string |
the delimiter |
return value |
xs:string? |
XQuery Function DeclarationSee XSLT definition. | declare namespace functx = "http://www.functx.com";
declare function functx:substring-before-if-contains
( $arg as xs:string? ,
$delim as xs:string ) as xs:string? {
if (contains($arg,$delim))
then substring-before($arg,$delim)
else $arg
} ; |
ExamplesXQuery Example | Results |
---|
functx:substring-before-if-contains('abcd','c') |
ab |
functx:substring-before-if-contains('abcd','x') |
abcd |
See AlsoHistory |
Recommended Reading:
|