RE: [xsl] Ann: Transforming J S O N in pure X S L T

Subject: RE: [xsl] Ann: Transforming J S O N in pure X S L T
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 10 May 2007 00:04:20 +0100
>   BTW, is it legal to have a compile error for the
> following:
> 
>     <xsl:variable name="..." as="item()" select="
>         if ( $... ) then ... else ()"/>
> 
> ?  Note I'm just curious, I love having early reporting on 
> such issues.
> 

Yes. Section 2.9:

"Certain errors are classified as type errors... An implementation may
signal a type error during the analysis phase in the same way as a static
error, even if it occurs in part of the stylesheet that is never evaluated,
provided it can establish that execution of a particular construct would
never succeed."

Note that this doesn't permit "pessimistic static type checking" as used in
some XQuery implementations, which throws out a construct if it might
sometimes fail. You can only throw it out if it can never be evaluated
successfully: that is, if the inferred static type of the construct and the
required type are completely disjoint. In this example the inferred static
type of () shows that it can never satisfy the required type item().

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

Current Thread