Re: [xsl] normalize-space and newlines

Subject: Re: [xsl] normalize-space and newlines
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Aug 2005 18:10:50 +1200
> Date: Wed, 24 Aug 2005 00:32:28 -0400
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> From: david_n_bertoni@xxxxxxxxxx
> Subject: Re: [xsl] normalize-space and newlines
> Message-ID: <OF8DBA1050.3B254F3A-ON88257067.00172602->
88257067.00191C5B@xxxxxxxxx>

Hi David, thanks for your help.

> This template has no "mode" attribute, so it's never matched.
>  This brings up the question as to why you are using modes at all,
> when all of your templates have apply-templates instructions that
> all use the same mode.

Um, because I don't know what I'm doing :-)
I copied somebody's identity template and it used mode="copy" throughout.
I added the normalize-space in a template matching text() items because it
looked like I could do it in the same pass (and I can, just not the way I
was doing it; I presumed that setting a higher priority would be enough).

>> <!-- non-empty: has children, is a text node, has value or attribute -->
>> <xsl:if test="node() or * or text() or string(.) or @*">

> The expression of the xsl:if "test" attribute seems strange to me.

And to me, it got to be what it was because terser expressions always seemed
to let stuff through that I didn't want to keep.

> Is there any reason why you don't have a separate template for element
nodes?
> <!-- Drop any empty elements -->
> <xsl:template match="*[not(node())]" mode="copy" />

I tried this with match="not(node())" which did not do what I wanted. Didn't
try *[note(node())] because expressions like that don't seem to occur to me
yet :-(

Cheers
Trevor

Current Thread