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
normalize-space(' query ')
query
normalize-space('xml query')
xml query
normalize-space('xml       query')
xml query
normalize-space('xml
query')
xml query
normalize-space('')
zero-length string
normalize-space('   ')
zero-length string
normalize-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/
Need XSLT Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley