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

How to remove (in addition) empty attributes?

Subject: How to remove (in addition) empty attributes?
From: "Ben Stover" <bxstover@xxxxxxxxxxx>
Date: Wed, 02 Dec 2009 15:30:59 +0100
 How to remove (in addition) empty attributes?
Assume I have a XML (sub)structure like:

....
<ns1:aaaa myattr="">
  <ns2:bbb/>
  <ns3:ccc/>
</ns1:aaaa>
....

and apply the XSLT template shown at the bottom of this email then all empty elements
are removed but the outer element aaaa (and its empty attribute) remains:

In detail the result will be:

<ns1:aaaa myattr=""/>

How can I delete empty attributes as well?

I guess the removal of empty attributes must be performed before the removal of
empty elements in order to detect really all empty elements.

Ben


"remove only empty elements script so far":

<?xml version="1.0"?>
<xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  
  <xsl:output indent="yes"/>

  <xsl:template match="*[not(node())]"/> 
  
  <xsl:template match="@* | node()">
     <xsl:copy>
       <xsl:apply-templates select="@* | node()"/>
     </xsl:copy>
  </xsl:template>
   
</xsl:stylesheet>

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.