Re: [xsl] White space treatment issue

Subject: Re: [xsl] White space treatment issue
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Tue, 18 Jan 2011 00:11:10 +0000
On 17/01/2011 23:20, Karl Stubsjoen wrote:
I can't figure out where/when white space is getting introduced, and
if it is introduced in the stylesheet or the xml document or I guess
maybe both.
I am using MvpXslTransform in a C# .NET application.
When I run the transformation straight with Saxon there is no issue.
When I run the same thing with MvpXslTransform, I get extra spaces in
the output.  There is linefeed-treatment set to true in the fo
document, but somehow extra lines are injected.

First, eliminate XSL-FO from the equation. Is the XSLT output different from the two processors?

Unwanted whitespace in XSLT output comes from one of three places:

(a) whitespace being copied from the source document

(b) whitespace copied from the stylesheet

(c) indentation added by the serializer

First see what the extra whitespace looks like. Is it adjacent to non-whitespace text. If so, where does that text come from? Is it in mixed content elements or in element-only content? Does it include newline characters? Is it the entire content of an element? This information will often lead you to identify one of the three causes above as the most likely.

The fact that you're getting different output from different processors is another clue. It tends to suggest a difference in parsing or serialization behaviour rather than in the transformation proper.

Michael Kay

Current Thread