Removes the leading and trailing white space and replaces the duplicate white space characters by a single space from $string-var.
As part of the removal process, the following steps occur:
If the value of $string-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
xf:normalize-space(xs:string? $string-var) —> xs:string?
Returns the $string-var after it has gone through the white space removal process (described above).
As part of the conversion process, contiguous sequences of spaces (#x20) are collapsed to a single space (#x20) and leading and trailing spaces (#x20) are removed, as shown in the following example query:
<result>{xf:normalize-space(" x y z ")}</result>
The preceding query, generates the following XML result:
<result>x y z</result>
Invoking normalize-space(()) returns the null string as shown in the following example query:
<result>{xf:normalize-space(())}</result>
Note: The string: () is the empty sequence (similar to a SQL null) which is a sequence containing zero items.
The preceding query generates the following result:
<result/>
W3C normalize-space function description.