Saxonica.com

Building source documents

To conform with the W3C Data Model specification, an incompatible change has been introduced in this release: by default, "ignorable whitespace" is stripped from source documents before a query or transformation commences.

If the document has a DTD, then ignorable whitespace is whitespace appearing between the child elements of an element that is declared to have element-only content. Such whitespace is always reported as such when a validating parser is used, but there appear to be differences between parsers as to whether it is reported when not validating.

If the document has a schema, then ignorable whitespace is a whitespace text node appearing as a child of an element that has element-only content.

If there is no DTD and no schema, then whitespace is never ignorable.

The presence of an xml:space="preserve" attribute has no effect on this process.

This whitespace stripping is additional (and prior) to any whitespace stripping requested using xsl:strip-space in an XSLT stylesheet. It occurs only when a document is built from a StreamSource or SAXSource.

The default behavior can be overridden from the command line. The Transform and Query commands have three new options: -snone strips no whitespace, -signorable strips ignorable whitespace, and -sall strips all whitespace text nodes.

It is also possible to override the default behavior when using the doc() or document() function, if query URI parameters are enabled, by adding the parameter strip=no to the URI.

Next