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

Subject: Re: [xsl] How to remove (in addition) empty attributes?
From: Syd Bauman <Syd_Bauman@xxxxxxxxx>
Date: Thu, 10 Dec 2009 11:28:34 -0500
> are you sure that the (your) line should look like
>  <xsl:template match="*[normalize-space( concat(.,@*) )='']"/>
> and not like
>  <xsl:template match="@*[normalize-space( concat(.,@*) )='']"/>
> Mind the @

I am quite sure I meant to match elements, not attributes, with that
template. I am not at all sure that's what you want, though :-)

I, for one, would probably find it easier to figure out the desired
behavior, here, if you posted a test file input and output. E.g., what
should the output be if the input is

 <?xml version="1.0" encoding="UTF-8"?>
 <wrapper>
   <!-- elements w/o content -->
   <outer></outer>
   <outer maybe=""></outer>
   <outer maybe="a"></outer>
   <!-- elements w/ PCDATA content -->  
   <outer>b</outer>
   <outer maybe="">b</outer>
   <outer maybe="b">b</outer>
   <!-- elements w/ an empty child element -->
   <outer><inner/></outer>
   <outer maybe=""><inner/></outer>
   <outer maybe="c"><inner/></outer>
   <!-- elements w/ a child element that has PCDATA content -->
   <outer><inner>d</inner></outer>
   <outer maybe=""><inner>d</inner></outer>
   <outer maybe="d"><inner>d</inner></outer>
   <!-- empty comment -->
   <!---->
   <!-- PIs -->
   <?syd the next PI is empty?>
   <?syd?>
 </wrapper>

(There may be situations I haven't taken into account for you, here:
it's the idea that counts.)

Note that Michael has since pointed out that the "concat(.,@*)"
construction (which I just copied from somewhere else in the
discussion) does not do what I thought it did. See
http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/200912/msg00138.html.

Current Thread