home contribute faq download

FunctX XSLT Functions

fn:normalize-space

Normalizes whitespace

Google
Webxsltfunctions.com

Description

The fn:normalize-space function collapses whitespace in a string. Specifically, it performs three steps:

  1. Replaces each carriage return (#xD), line feed (#xA), and tab (#x9) character with a single space (#x20)
  2. Collapses all consecutive spaces into a single space
  3. Removes all leading and trailing spaces

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameType
$arg xs:string?
return value xs:string

Examples

XSLT ExampleResults
<normalize-space('query'>
<query>uery
<normalize-space(' query '>
<query>uery
<normalize-space('xml query'>
<xml>ml query
<normalize-space('xml       query'>
<xml>ml query
<normalize-space('xml
query'>
<xml>ml query
<normalize-space(''>
zero-length string
<normalize-space('   '>
zero-length string
<normalize-space(())>ormalize-space(())
zero-length string

See Also

functx:trimTrims leading and trailing whitespace
functx:left-trimTrims leading whitespace
functx:right-trimTrims trailing whitespace

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XSLT Services

Recommended Reading:

XQuery