[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Stripping empty elements while still conforming to

Subject: Re: Stripping empty elements while still conforming to DTD
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 28 Sep 2005 17:16:08 +0100
xslt strip empty elements
> 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. 

It depends what you mean by simple. XSLT has no access to the
declarations in a DTD (or at least the XSLT programmer has no access via
XSLT) so you have to put the information in "by hand" so it's simple but
tedious if the dtd is big

<xsl:template match="*[not(node())]"/> 
zaps all empty elements, except...

<xsl:template match="wibble/[not(node())]">
<xsl:copy-of select="."/>
</xsl:template>

empty elements that are children of wibble, which are copied.

David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.