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



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)
** I think we should keep Libxslt's behaviour here; although this is
  an ugly case, since it will generate different results if using XSLT
2.0
  processors. I'm surprised that this is the de facto behaviour of
  Xalan-J and MSXML .NET.

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
** I think we should keep Libxslt's behaviour here.

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)
** I think we should relax Libxslt's behaviour here and strip the
whitespace.

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
** I think we should relax Libxslt's behaviour here and strip the
whitespace.

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)
** Here we should fix Libxslt in order to allow only whitespace.

MSXML .NET : invalid
Saxon 8.5.1: allowed

Regards,

Kasimier



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]