|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Recursively removing empty tags from deepest child
> I'm trying to remove certain empty tags from a set a files
>
> e.g., simplified example
>
> <?xml version="1.0" encoding="US-ASCII"?>
> <bdy>
> <section><p>not empty</p><p></p></section>
> <section><section><p></p></section></section>
> </bdy>
>
>
> I want
>
> <?xml version="1.0" encoding="US-ASCII"?>
> <bdy>
> <section><p>not empty</p></section>
> </bdy>
>
>
> i.e. in this example in the first section the empty <p></p>
> is removed and the
> whole of the second section removed since it contains just an
> empty p and
> empty section elements.
How about only copying a node through if it has a text() descendant:
<xsl:template match="@*|*">
<xsl:copy>
<xsl:apply-templates select="@*|*|text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[not(.//text())]"/>
Out of interest, can anyone with a knowledge of template matching
complexity tell me if this is O n^2 or if because it is within a match
pattern some other rule applies?
cheers
andrew
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








