RE: [xsl] XPath "none" /type/ not available to the user

Subject: RE: [xsl] XPath "none" /type/ not available to the user
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 24 May 2006 14:28:08 +0100
In Saxon I implement error() with a static return type of item(). This
ensures that a call on error() never generates a static type error. Saxon
does "optimistic static typing", reporting an error at compile time only if
the supplied type and the expected type are disjoint. If you do pessimistic
static typing (where the static type must be subsumed by the expected type)
then handling of error() has to be special-cased in some way: I don't fully
understand this because I've never got into the detail of pessimistic static

You might find it more productive to discuss this on xquery-talk, where you
are more likely to find people interested in the formal semantics of the
type system.

Michael Kay

> -----Original Message-----
> From: Frans Englich [mailto:frans.englich@xxxxxxxxx] 
> Sent: 24 May 2006 14:26
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] XPath "none" /type/ not available to the user
> On Wednesday 24 May 2006 12:40, Florent Georges wrote:
> > Frans Englich wrote:
> > > On Wednesday 24 May 2006 11:26, Florent Georges wrote:
> > > >   Why is it not available to the user?
> > >
> > > Probably because no one thought a reasonable usage 
> scenario exists 
> > > for it(although I don't know for sure).
> >
> >   A custom error reporting function (based on fn:error()) 
> is an enough 
> > interesting use case, isn't it?  But more generaly, if a system 
> > function returns such an absorbent type [1], you'll need 
> one time or 
> > another to use this type, IMHO.
> Yes, I guess it is. Will be interesting to see what Michael 
> says if he follows up this thread.
> You can skip declaring the return type of the function, then 
> the return type is inferred from the function body. I agree 
> this is hackish though.
> In what scenario does empty-sequence() not work for you? It 
> must be some rare cases where empty-sequence() doesn't work 
> and one must use 'none'.
> > > I've myself been thinking a bit about this, while writing XQuery 
> > > test cases.  Try declaring a function with the return type 
> > > empty-sequence()
> >
> >   I didn't try to really test it.  Actually, with Saxon 
> 8.7.1j we can 
> > use every SequenceType (for example xs:string, node(), 
> > empty-sequence() or text()), even with the '+'
> > occurrence indicator.  As if no static type checking was 
> made at all.  
> > As if this special case was banned from the static type checking 
> > engine.
> The 'none' type intentionally "disappears" in the type system 
> such that one can insert the fn:error() function anywhere 
> without getting a type error.
> Cheers,
> 		Frans

Current Thread