normalize-space
The normalize-space function (see screenshot below) removes leading and trailing spaces of a string and replaces internal whitespaces with a single whitespace character. Whitespace includes space (U+0020), tab (U+0009), carriage return (U+000D), and line feed (U+000A) characters. For details about whitespaces, see the XML Recommendation.

About non-breaking spaces
The left-trim, right-trim, and normalize-space functions do not remove non-breaking spaces. One of the possible solutions could be to replace the non-breaking space character, whose decimal representation is 160, with the space character, whose decimal representation is 32. The mapping below shows that after the non-breaking space has been replaced, the trimmed SomeValue value will be mapped to the target.

If your source component is an Excel file, you can remove extra spaces in Excel using a combination of TRIM, CLEAN, and SUBSTITUTE functions. For details, see Removing Spaces and Nonprinting Characters from Text.
Languages
Built-in, C++, C#, Java, XQuery, XSLT 1.0, XSLT 2.0, XSLT 3.0.
Parameters
Name | Description |
---|---|
string | The input string to normalize. |
Example
If the input string is " The quick brown fox ", the function returns "The quick brown fox".