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

Subject: Re: [xsl] How to remove (in addition) empty attributes?
From: "Ben Stover" <bxstover@xxxxxxxxxxx>
Date: Thu, 03 Dec 2009 08:40:27 +0100
The problem with this is that only elements OR attributes are stripped but not both at the same time.

Assume the following XML source:

<ns11:elem1 myattr="">
   <ns22:subelem2 />

Then applying the XSLT script below will result in


As you can see the ns11:elem1 persists.
It is handled only in the remove attribute template and does not match the other remove-empty-element template. 

So how can I iteratively/recursively re-apply the script/templates on the result again?

XSLT script:

<?xml version="1.0"?>
<xsl:stylesheet   xmlns:xsl="";  version="1.0">
  <xsl:output indent="yes"/>

  <xsl:template match="@*[normalize-space(.)='']"/>

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

On Wed, 2 Dec 2009 20:58:11 -0500, Syd Bauman wrote:

>How about matching the empty attributes and not generating any

>  <xsl:template match="@*[normalize-space(.)='']"/>

>> How can I delete empty attributes as well?

Current Thread