This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Removing tags automatically efter xsl transformation!
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] Removing tags automatically efter xsl transformation!
- From: gutman at novosoft-us dot com
- Date: Tue, 7 Aug 2001 19:42:38 +0700
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hello.
Klosa Uwe wrote:
> I want to remove tags like <tag/> (without any child and string-length
of
> zero) from my output. I'm transforming xml-files to different formats.
In
> some I don't want to have "empty" tags.
Do you want
(1) to remove all elements with empty content or
(2) to prevent their appearance in the output?
These are different wiches.
For instance, what you want to do with the following input?
<one>
<two>
<three/>
</two>
<one/>
If you want (1) then the output will be
<one>
<two/>
<one/>
But if you want (2), I guess, the output will be empty.
In the case of (1), here is a solution:
<xsl:template match="*">
<xsl:if test="node()">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>
As for (2), I will start thinking
only after you say you really want it. :-)
--
Alexander E. Gutman
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list