[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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


Subject: Re: [xsl] How to prevent blank lines and blank inserts for this script?
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Mon, 7 Dec 2009 15:35:54 +0000

Add <xsl:strip-space elements="*"/> as a top level element

cheers
andrew

2009/12/7 Ben Stover <bxstover@xxxxxxxxxxx>:
> 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>
>
>



--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/


Current Thread
Keywords