Re: Bug 4378: absent context item

On 05/11/2015 09:10, Michael Kay wrote:
>> On 4 Nov 2015, at 13:21, Tim Mills <tim@cbcl.co.uk> wrote:
>>
>> I think it is unfortunate that we say that the "context item static type component is absent[DM30]." without saying in 2.1.1 Static Context:
>>
>> [Definition: Context item static type. This component defines the static type of the context item within the scope of a given expression.  It may be a type, or absent ]
>>
>> The above change would make it clear that this component of the static context can be absent.
> 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.
>
>> Looking at XSLT's context item declaration, it appears that XSLT never permits the static type of the context item to be absent because
>>
>> <xsl:global-context-item use="absent" />
>>
>> is equivalent to
>>
>> <xsl:global-context-item use="absent" as="item()" />
>>
>> It's quite explicit: the value may be absent, but it's static type definitely is not.
> Actually this declaration isn’t allowed (in the latest draft): use=“absent” means there will be no context item, and you’re not allowed to specify a type for something that won’t ever exist. Only one possible state for the context item is permitted with this declaration, namely absence.

Oh, I was reading:

https://www.w3.org/XML/Group/qtspecs/specifications/xslt-30/html/Overview.html#element-global-context-item

which states

If the |as| attribute is present then its value must be an ItemType 
<http://www.w3.org/TR/xpath-30/#prod-xpath30-ItemType>^XP30 . If the 
attribute is omitted this is equivalent to specifying |as="item()"|.

> Omitting a global-context-item declaration 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.  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.

Cheers,
     Tim

Received on Monday, 9 November 2015 13:21:26 UTC