xsl-list
[Top] [All Lists]

[xsl] How to remove (in addition) empty attributes?

2009-12-02 19:51:00
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>









--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--