[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Stripping empty elements while still conforming to DTD


Subject: Re: [xsl] Stripping empty elements while still conforming to DTD
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Wed, 28 Sep 2005 17:13:30 +0100

On 9/28/05, watchstone@xxxxxxxxxxx <watchstone@xxxxxxxxxxx> wrote:
> Is there a simple way to strip empty elements from an XML while still
conforming to the requirements of the DTD?  I know how to use the string()
function to copy only those elements that contain data, but this often removes
child elements required by the DTD.

You mean text() right?  And how can you make choices in the stylesheet
based on the DTD - the stylesheet doesn't know about the DTD.

If you mean you don't want to copy nodes without any children through
to the output, then you want a no-op template:

<xsl:template match="*[not(node())]"/>

...or something similar, depending on the rest of your stylesheet.  An
example of what you are trying to achieve would be good here.


Current Thread
Keywords
xml