Re: [xsl] using normalize-space with mixed element content (more info)

Subject: Re: [xsl] using normalize-space with mixed element content (more info)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 09 Jun 2010 00:56:22 +0100
On 09/06/2010 00:44, Lynn Murdock wrote:
i'm using xslt 2.0, with saxon (8.7), integrated into an IDE (intellij).

saxon 8's pretty old, any reason not to be using 9?

i also forgot to mention that normalize-space is not removing the whitespace between the italic tags, it's just stripping the italic formatting.

That doesn't sound likely, are you sure?
normalize-space requires a string as input so if you give it an element with mixed content it starts off by taking the string value of the content (so just gets the character data) it is this string value that is then normalized, so any runs of white space within a nested element should be converted to a single space (or dropped completely if they constitute either end of the entire string).

All the solutions given so far work with xslt 2 (mine also xslt 1)
which you want depends on which you want, specifically whether you need runs of space to be converted to a single #20 character (as normalize-space would do, (only mine did that) whether you want space stripped if it occurs at the end but in a child element (only Gerrit's did that) or whether you wanted it to be succinct and understandable (Michael's version)


Current Thread