xsl-list
[Top] [All Lists]

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

2008-10-08 07:06:43
What is happening here is that Saxon is detecting the type error dynamically
(at execution time) rather than statically (at compile time), which means it
doesn't get detected if the variable is never used (variables that are never
used are never evaluated).

This is entirely conformant behaviour - run-time errors aren't reported if
the code doesn't get evaluated, and it's up to the processor to decide
whether or not it needs to evaluate the code in order to produce a result.

It looks as if there's room for some extra static type checking here,
however. Again, that's at the discretion of the processor.

Michael Kay
http://www.saxonica.com/

-----Original Message-----
From: Mukul Gandhi [mailto:gandhi(_dot_)mukul(_at_)gmail(_dot_)com] 
Sent: 08 October 2008 11:45
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] XSLT 2.0 processor signalling error, for type errors

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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--