Over a million developers have joined DZone.

Normalize Space And Keep Line Breaks In XSTL

XSLT function pattern to normalize space but keep line breaks, without using a template.

It replaces both line break characters with non-whitespace placeholders, normalizes, then puts the line breaks back in, nothing fancy. Note that it will handle all four types of line breaks (LF, CR, CRLF, LFCR) even though only LF is XML standard. In our case, the placeholders are characters 160 and 173, the hard space and soft hyphen respectively. They're used, but generally only by programmers and Office documents.

For reference, pretend "FieldValue/." is the path to a foo element.

  translate(FieldValue/., '

', ' ­')
 ), ' ­Â­', '



{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}