RE: [xslt] Validation of the content of xsl:template


> -----Original Message-----
> From: xslt-bounces gnome org [mailto:xslt-bounces gnome org] 
> On Behalf Of Buchcik, Kasimier> 


> Example - this stylesheet is not valid, since it has a text-node
> before xsl:param; although it's a whitespace-only text-node, the
> xml:space does preserve it. Currently this text-node is incorrectly
> treated as "template" content, thus added to the output tree.
> <xsl:stylesheet version="1.0"
>     xmlns:xsl="";>
>   <xsl:template match="/" xml:space="preserve">
>     <xsl:param name="foo"/>
>   </xsl:template>
> </xsl:stylesheet>
> As per XSLT 1.0, the above example is incorrect.
> XSLT 2.0 stripps whitespace-only text before xsl:param
> regardless of what xml:space indicates.
> So we have the following possibilities:
> 1) Keep the broken behaviour.
>    This would obviously change nothing.
> 2) Apply validation as defined by XSLT 1.0
>    This would raise errors in existing broken stylesheets.
> 3) Go the XSLT 2.0 way and strip the whitespace.
>    This would raise no error, but produce a different result.

Additional tests revealed that the current behaviour of Libxslt
wrt to whitespace before xsl:param is the de facto behaviour of
Xalan-J and MSXML .NET, so we could consider to keep that.
This means that such whitespace before xsl:param will become part
of the "template" and will be added to the result tree.
Note that this deviates from the spec and is incompatible with
XSLT 2.0 processors, which will strip any whitespace before
xsl:param (regardless of xml:space).

Note also that Saxon rejects such broken stylesheets.

However any other content (non-whitespace text, literal
result elements, instructions, etc.) won't be allowed in the
refactored code.



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