Name

normalize-space( ) — returns the src with certain whitespace characters collapsed

Synopsis

Defined in: XPath 1.0
Parameters: string src (optional)
Return type: string

This function removes all leading and trailing whitespace, and all other consecutive whitespace characters are replaced with a single space. When called with no parameters, returns the normalized value of the context node converted to a string.

This example returns “Hello World!”:

normalize-space("  Hello   World!   ")

Get XForms Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.