[xsl] <xsl:strip-space> does NOT work when comment lines are involved (directly before).

Subject: [xsl] <xsl:strip-space> does NOT work when comment lines are involved (directly before).
From: "Ben Stover" <bxstover@xxxxxxxxxxx>
Date: Tue, 08 Dec 2009 10:12:01 +0100
In my previous posting I asked for a way to prevent blank lines.

Some users recommend to insert 

   <xsl:strip-space elements="*"/>

on top of the XSLT script. That work fine as long as there are no comments involved (directly before).
However when I have an input.xml file like

<!-- some comment -->

then the resulting output.xml would be:

<!-- some comment --><ns2:ccc>456</ns2:ccc>

Mind the appended XML node DIRECTLY AFTER the comment on the same line!
How can I let XSLT insert/keep the CR/eol char after the comment line
AND the keep indent (for node <ns2:ccc>?

Furthermore with 

   <xsl:strip-space elements="*"/>

ALL existing blank lines are removed. But I want to remove only these blank lines which are created
when empty elements are removed (with the templates of the remaining script). 

How can I achieve this?


The current xslt script would be:

<?xml version="1.0"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

   <xsl:strip-space elements="*"/>

   <xsl:output indent="yes"/>
   <xsl:template match="@* | node()">
       <xsl:apply-templates select="@* | node()"/>
   <xsl:template match="*[normalize-space( concat(.,@*) )='']"/>

Current Thread