RE: [xsl] Operation of indent="yes" in Saxon 6.5.2 vs MSXML

Subject: RE: [xsl] Operation of indent="yes" in Saxon 6.5.2 vs MSXML
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 26 Jun 2002 09:06:45 +0100
MSXML has the "feature" that it strips whitespace on the input document
by default. This contravenes the spirit (though arguably not the letter)
of the XML and XSLT specifications. Saxon doesn't do this: whitespace in
the source document is retained unless you strip it using
xsl:strip-space.

The XSLT spec for indent="yes" only allows whitespace to be added to the
document, it does not allow whitespace to be removed. Generally
indent="yes" only works well in an environment where whitespace is
insignificant, in which case it usually makes sense to use
xsl:strip-space at the same time.

However, using indent="yes" to add whitespace just so that another phase
of transformation can remove it is incredibly wasteful. The indent="yes"
option should really be used only when the XML is intended for human
consumption, otherwise it's just a waste of processor cycles.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Michael Leditschke
> Sent: 26 June 2002 06:50
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Operation of indent="yes" in Saxon 6.5.2 vs MSXML
> 
> 
> I have a series of stylesheets applied sequentially to a 
> document. Each stylesheet has the indent="yes" attribute set.
> 
> When I use MSXML, no matter how many transforms I apply, the 
> only whitespace I get between tags is a single linefeed.
> 
> When I use Saxon 6.5.2, each transform is adding a linefeed 
> followed by 3 spaces per indent level. So the more 
> transforms, the more 
> whitespace.
> 
> I realise the behaviour of indent is processor dependent and 
> the spec doesn't specify how to add the whitespace, but I 
> would expect the amount of whitespace used to achieve the 
> indent effect would remain constant across multiple 
> transforms rather than being additive.
> 
> Example XML file
> 
> <A>
> <B>
> <C/>
> </B>
> <A>
> 
> Example Stylesheet
> 
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>   <xsl:output encoding="UTF-8" indent="yes"/>
>   <xsl:template match="/">
>     <xsl:copy-of select="."/>
>   </xsl:template>
> </xsl:stylesheet>
> 
> After two stylesheets;
> 
> MSXML
> 
> <A>
> <B>
> <C/>
> </B>
> <A>
> 
> SAXON
> 
> <A>
> 
>              <-- Three spaces here as well
>    <B>
> 
>              <-- Three spaces here as well
>       <C/>
> 
>              <-- Three spaces here as well
>    </B>
> 
>              <-- Three spaces here as well
> <A>
> 
> 
> Is this the expected behaviour of SAXON in this situation?
> 
> Regards
> Michael
> 
> P.S. I was using MSXML within XMLSpy but found it hung on
> some large files, so dropped back to a command prompt and
> tried it with SAXON. It worked and was much quicker, but 
> I ran across the above feature in the process.
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread