RE: [xsl] Effects of white space between xml elements

Subject: RE: [xsl] Effects of white space between xml elements
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 23 Feb 2009 23:15:38 -0000
> Does white space between elements of an xml document effect 
> the output of a transformation of that document?

In general yes.

> If tags are nested properly, shouldn't white 
> space and new lines in between elements be irrelevant?

No. Consider:

<p>He was <i>nearly<i> <i>twelve</i>.</p>

Note however that many products give you the option to get rid of
inter-element whitespace when processing the kind of XML where you don't
want it. You can control this from the stylesheet using xsl:strip-space.
MSXML, notoriously, gets rid of it by default, causing data such as the
example above to be rendered incorrectly.

(On page 1005 of my XSLT 2.0 book is a screen shot showing how the XML 1.0
Recommendation displays incorrectly in Internet Explorer as a direct result
of this).

Michael Kay
http://www.saxonica.com/

Current Thread