xsl-list
[Top] [All Lists]

[xsl] How to prevent blank lines and blank inserts for this script?

2009-12-07 10:33:32
When I apply the XSLT script at the bottom of this posting then it works fine
in general. The purpose is to remove empty elements and empty attributes.
But I guess this purpose is not important.

However there is one problem. The result XML doc contains a blank line at the 
location of the removed element and the following element is shifted some 
blanks 
to the left border. Simplified example for the input.xml:

...
(3 blanks)<ns1:myelem>
(6 blanks)<ns2:aaa>123</ns2:aaa>
(6 blanks)<ns2:bbb></ns2:bbb>
(6 blanks)<ns2:ccc>456</ns2:ccc>
(3 blanks)</ns1:myelem>
...

I am getting an output.xml similar to:

...
(3 blanks)<ns1:myelem>
(6 blanks)<ns2:aaa>123</ns2:aaa>
(3 blanks)
(2 blanks)<ns2:ccc>456</ns2:ccc>
(3 blanks)</ns1:myelem>
...

How do I get rid of the blank line?
How do I get rid of the left shift of element <ns2:ccc>

Ben

XSLT script:

<?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="@* | node()">
     <xsl:copy>
       <xsl:apply-templates select="@* | node()"/>
     </xsl:copy>
   </xsl:template>
   
   <xsl:template match="*[normalize-space( concat(.,@*) )='']"/>
   
</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>
--~--

<Prev in Thread] Current Thread [Next in Thread>