Re: Bug 4378: absent context item

>> But it doesn’t make it clear what the absence of the component means. Does it mean there will be no context item, or does it mean we don’t know whether or not there will be a context item, or does it mean there will be a context item but we don’t know anything about its type?
> 
> 
> None of the above.  If the context item static type is absent, then the context item is out-of-scope, just as in the case where the static context contains no mapping for the static type of a variable name.  This leans me back in the direction of XPST0008.

Is your statement "the context item is out-of-scope" any different from my statement "there will be no context item"?
>> Omitting a global-context-item declaration [in XSLT] is equivalent to specifying
>> 
>>> <xsl:global-context-item use=“optional" as="item()" />
>> This declaration defines the set of possible states of the context item to include any item, plus absence.
>> 
>> I don’t find the notion of the static type being “absent” helpful without a clear understanding of what the absence of a static type tells us about the set of possible dynamic states. 
> 
> It tells us nothing about the possible dynamic states, because it identifies a static error.  

No, the declaration <xsl:global-context-item use=“optional" as="item()" /> says (a) if you supply a global context item then it must be an item (trivially true), and (b) if you don't supply a global context item then any reference to "." (etc) is a dynamic error XPDY0002.

We can raise the error statically if you specify use="required", but not if you leave it at the default use="optional".

We allow users to write:

<xsl:variable name="context-item-if-supplied" as="item()?">
  <xsl:try select=".">
   <xsl:catch errors="*:XPDY0002" select="()"/>
 </xsl:try>
</xsl:variable>

I'm reluctant to lose that capability.

Michael Kay
Saxonica

Received on Monday, 9 November 2015 15:01:05 UTC