[xsl] Matrix of differences wrt preserved-whitespace in XSLT 1.0 instructions

Subject: [xsl] Matrix of differences wrt preserved-whitespace in XSLT 1.0 instructions
From: "Buchcik, Kasimier" <k.buchcik@xxxxxxxxxxxx>
Date: Tue, 9 May 2006 12:55:34 +0200
Hi,

This is a JFYI. I compiled a matrix showing the difference in
handling of preserved-whitespace in the content of XSLT 1.0
instructions.

The following is invalid for XSLT 1.0 processors: there
must be no content in an xsl:template before an xsl:param.

Example template:
  <xsl:template match="/" xml:space="preserve">
    <xsl:param name="foo"/>
    <foo/>
  </xsl:template>

Result:
<?xml version="1.0"?>


    <foo/>

Processor-behaviour:
Saxon 6.5.3: invalid
Xalan-J    : allowed (part of template)
Libxslt    : allowed (part of template)
MSXML .NET : allowed (part of template)
Saxon 8.1.1: allowed (in XSLT 2.0 such whitespace is stripped;
                      not part of template)

With Libxslt, Xalan-J and MSXML .NET, the whitespace before xsl:param
is handled as being part of the "template"; thus added to the
result-tree.

-----

The following is invalid for XSLT 1.0 processors: there
must be no text in the content of xsl:choose.

Example template:
  <xsl:template match="/" xml:space="preserve">
    <foo><xsl:choose>
      <xsl:when test="true()"><bar/></xsl:when>
    </xsl:choose></foo>
  </xsl:template>

Processor-behaviour:
Saxon 6.5.3: invalid
Xalan-J    : allowed
Libxslt    : allowed
MSXML .NET : allowed
Saxon 8.5.1: allowed (in XSLT 2.0 such whitespace is stripped)

I think we should keep the current relaxed behaviour of Libxslt as it is
compatible with Xalan-J, MSXML .NET and XSLT 2.0 processors.

-----

The following is invalid for XSLT 1.0 processors: there
must be no content in an xsl:for-each before an xsl:sort.

Example template:
  <xsl:template match="/">
    <foo>
      <xsl:for-each select="/foo/bar" xml:space="preserve">
<xsl:sort/><xsl:value-of select="."/></xsl:for-each>
    </foo>
  </xsl:template>

Result:
<?xml version='1.0' ?>
<foo> a b c</foo>

Processor-behaviour:
Saxon 6.5.3: allowed (part of template)
Xalan-J    : allowed (part of template)
Libxslt    : invalid (error raised at transformation-time)
MSXML .NET : allowed (part of template)
Saxon 8.5.1: allowed (in XSLT 2.0 such whitespace is stripped;
                      not part of template)

With Saxon 6.5.3, Xalan-J and MSXML .NET the whitespace is handled as
being
part of the "template"; thus it is added to the result-tree.

-----

The following is invalid for XSLT 1.0 processors: there
must be no text in the content of an xsl:call-template and
xsl:apply-templates.

Example templates:
  <xsl:template match="/">
    <xsl:call-template name="foo" xml:space="preserve">
      <xsl:with-param name="param"/>
    </xsl:call-template>
  </xsl:template>

  <xsl:template name="foo">
    <foo/>
  </xsl:template>

Processor-behaviour:
Saxon 6.5.3: allowed
Xalan-J    : allowed
Libxslt    : invalid
MSXML .NET : allowed
Saxon 8.5.1: allowed (in XSLT 2.0 such whitespace is stripped)

-----

The following is invalid for XSLT 1.0 processors: the instructions
xsl:apply-imports, xsl:copy-of, xsl:number, xsl:sort and xsl:value-of
must have no content.

Example template:
 <xsl:template match="/">
    <xsl:copy-of select="foo" xml:space="preserve">
    </xsl:copy-of>
  </xsl:template>

Processor-behaviour:
Saxon 6.5.3: invalid
Xalan-J    : allowed
Libxslt    : allowed (any content is allowed)
MSXML .NET : invalid
Saxon 8.5.1: allowed

Current Thread