Re: [xsl] XSLT 2.0 processor signalling error, for type errors

Subject: Re: [xsl] XSLT 2.0 processor signalling error, for type errors
From: "Colin Adams" <colinpauladams@xxxxxxxxxxxxxx>
Date: Wed, 8 Oct 2008 11:53:48 +0100
While you are allowed to raise type errors at compile time, it is not
compulsory to do so.

2008/10/8 Mukul Gandhi <gandhi.mukul@xxxxxxxxx>:
> Hi all,
>  I tried following code with Saxon 9.1.0.2J (the, basic version),
>
> [1]
> <xsl:template match="/">
>  <xsl:variable name="temp" as="element()?">
>    123
>  </xsl:variable>
> </xsl:template>
>
> And Saxon doesn't show any error.
>
> But when I write the code as following,
>
> [2]
> <xsl:template match="/">
>  <xsl:variable name="temp" as="element()?">
>    123
>  </xsl:variable>
>  <xsl:copy-of select="$temp" />
> </xsl:template>
>
> Saxon displays following error,
>
> XTTE0570: Required item type of value of variable $temp is element();
> supplied value has item type text()
>
> In the first case ([1]), though the variable contents do not conform
> to the type declaration, no error is signalled.
>
> While in second case ([2]), the error is signalled, as the variable is
> copied to the result tree.
>
> Why is the error not signalled in 1st case? Does the XSLT 2.0 spec
> says anything about this issue? Or is this behavior Saxon specific
> (perhaps, is some kind of optimization)?
>
>
> --
> Regards,
> Mukul Gandhi

Current Thread