xsl-list
[Top] [All Lists]

[xsl] Remove element that all its descendants have no text nodes

2010-02-10 16:36:01
Hi,

I want to remove span elements that have empty text nodes and no
further descendants.
In case the p has ONLY empty spans I want to remove it alltogether.

Example:

<p dir="rtl"><span id="textStyle10"></span></p>
<p dir="rtl"><span id="textStyle10">Some text.</span> <span
id="textStyle10"></span></p>
<p dir="rtl"><span id="textStyle10"></span><sup>1</sup></p>
<p dir="rtl"><span id="textStyle10"><br /><br /></span></p>


Desired output:
<p dir="rtl"><span id="textStyle10">Some text.</span> </p>
<p dir="rtl"><sup>1</sup></p>
<p dir="rtl"><span id="textStyle10"><br /><br /></span></p>


In case it is too complicated I can live with such output (remove p
that all its spans have empty text nodes):
<p dir="rtl"><span id="textStyle10">Some text.</span> <span
id="textStyle10"></span></p>
<p dir="rtl"><span id="textStyle10"></span><sup>1</sup></p>
<p dir="rtl"><span id="textStyle10"><br /><br /></span></p>

I tried the following:
<xsl:template match="p[span[normalize-space(.)='']]"/>
but it removes the p even if only one span is empty.

Any help would be appreciated.

Thanks, Israel

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>