RE: [xsl] regarding strip-space

Subject: RE: [xsl] regarding strip-space
From: Jarno.Elovirta@xxxxxxxxx
Date: Tue, 16 Jul 2002 15:52:44 +0300
Hi,

> 1.what is a whitespace-only node?? ( is it an empty element of kind 
> <myel></myel>)??

It's text node, that contains only white space characters, i.e. space characters, carriage returns, line feeds, and tabs. The thingy you're describing above is just an element, that happens to have no children.

> 2.If i have empty elements like what i have shown above(<myel></myel>)
> and if i have to pick all the myel elements which have some 
> text in it ( non 
> empty ) then , i beleive the only way to do it is through a condition
> <xsl:for-each select = //myel[not(string-length(.) = 0)]">
> is it true??

here you have to make a difference between elements that are non-empty and elements that have text nodes as children. The predicate above will ignore e.g.

<myel><foo /></myel>

So if you need to test whether myel is an empty node, use

//myel[not(node())]

but if you want to test if myel has any text node children, you need test

//myel[not(text())]

Cheers,

Santtu

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread