Subject: [xsl] Re: regarding strip-space From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Tue, 16 Jul 2002 06:44:12 -0700 (PDT) |
> I read in the XSLT Reference that xsl:strip-space would actually > remove > the > whitespace-only text nodes from the source. > My question is ..( sorry its a bit weird) > 1.what is a whitespace-only node?? ( is it an empty element of kind > <myel></myel>)?? > No, a white-space-only node is a ***text*** node, not an element, consisting of any combination of the following characters: space ( ), tab (	), newline ( ) and carriage return ( ). > 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?? > > or are there any better ways to do it? > If by "elements which have some text in it" you mean to have a text-node child, then use the following: myel[text()] In case you need an element some of the descendents of which are text nodes (not necessarily its immediate children), the following XPath expression might be evaluated more efficiently: myel[descendant::text()] The XPath expression contained in your message: myel[not(string-length(.) = 0)] will also work in this case, but it requires that the concatenation of all text node descendents be constructed (probably some intelligent XPath engine will not do this?). ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL __________________________________________________ Do You Yahoo!? Yahoo! Autos - Get free new car price quotes http://autos.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] regarding strip-space, David Carlisle | Thread | [xsl] Sibling text nodes, John R. Daily |
Re: [xsl] regarding strip-space, David Carlisle | Date | RE: [xsl] regarding strip-space, Andrew Welch |
Month |