RE: [xsl] Ignorable whitespace and XSLT

Subject: RE: [xsl] Ignorable whitespace and XSLT
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 21 Feb 2005 15:29:09 -0000
> Note that the ignorable whitespace node between the opening tag <root>
> and the opening tag <leaf> is considered a significant node in XSLT
> processing - it is still there.
> Is this intended behaviour, and if so, why?

The designers of XSLT 1.0 made a decision that the result of processing a
source document should not depend on whether or not it was read by a
validating parser. I think this was done partly to ensure predictable
results, and partly because of belief (in 1999) that DTDs were on the way

There is in fact one feature that does depend on the DTD, namely the id()
function, and that's error-prone enough to justify the decision.

We've debated a number of times whether the rules should be changed in 2.0
to make whitespace-stripping sensitive to the schema, and the WG has decided
against. There's one exception, which is that it's now an error to request
stripping of an element if the element has a simple type definition. This is
because stripping the whitespace content of such an element could destroy
its validity. (There's also the blanket exception, which is that you can
construct a source tree any way you like, including by use of a builder that
*does* take schema information into account.)

Michael Kay

Current Thread