Subject: Re: XPath "none" /type/ not available to the user
From: Frans Englich <frans.englich@xxxxxxxxx>
Date: Wed, 24 May 2006 11:49:30 +0000
|
On Wednesday 24 May 2006 11:26, Florent Georges wrote:
> Hi
>
> In F&O, '3 The Error Function says:
>
> fn:error() as none
>
> [...]
>
> Note that "none" is a special type defined in [XQuery
> 1.0 and XPath 2.0 Formal Semantics] and is not available
> to the user. It indicates that the function never
> returns and ensures that it has the correct static type.
>
> 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).
> As the result type
> of a function that never returns. For example, what can I
> put in the @as of the following XSLT definition of an XPath
> function?
>
> <xsl:function name="my:error" as="none()">
> <xsl:param name="msg" as="xs:string"/>
> <xsl:sequence select="
> error($my:error-qname, concat('No luck: ', $msg))"/>
> </xsl:function>
>
> IMHO, it can be interesting for static type checking.
> Does this "type" introduces some complexity in the static
> type system?
I think implementors happily form a little choir singing "Yes it do! Tra la la
la!"
I've myself been thinking a bit about this, while writing XQuery test cases.
Try declaring a function with the return type empty-sequence():
<xsl:function name="my:error" as="empty-sequence()">
<xsl:param name="msg" as="xs:string"/>
<xsl:sequence select="
error($my:error-qname, concat('No luck: ', $msg))"/>
</xsl:function>
I haven't yet confirmed in Formal Semantics that this shouldn't be a type
error(e.g, that the type 'none' should match empty-sequence()), but it really
should due to the purpose of fn:error() and the none type.
Cheers,
Frans
(personal response)
|