[Bug 3818] Static typing of $input-context1/works[1]/employee[1]/empnum[1]

http://www.w3.org/Bugs/Public/show_bug.cgi?id=3818





------- Comment #12 from simeon@us.ibm.com  2007-02-20 01:15 -------
A couple of comments on this thread.

First, the type assertion let $x as Type := Expr ... has intentionally a
semantics different from 'treat as'. There used to be a distinction and a
separate operator in the language for it (called 'assert as') to allow user to
enforce a specific type and check that this is the correct type at both static
and run time. I think a large part of the thread (from comment #4 on) is
related to treat as. Although I agree with most of what is being said, I don't
think it should apply to the particular issue that is being reported here.

Second, I do think there is a problem with the particular query that Tim
reports. I think the intent is that his particular query should pass static
typing. The issue seems to be with the 'as node()' type assertion introduced
during normalization of step expressions. (5th normalization rule in Section
4.2 Path Expressions -- just before 4.2.1). I think a way to fix this issue
which is consistent with the rest of the spect is to introduce a special
function fs:node-sequence() which checks whether the input is a sequence of
nodes, and if yes propagates the corresponding input type as output. Such a
function could go after Section 7.1.4 and have the following typing rules:

statEnv  |-   Type <: node*
---------------------------------------------------------
statEnv |-  (FS-URI,"node-sequence") ( Type ) : Type

Comments?
- Jerome

Received on Tuesday, 20 February 2007 01:15:24 UTC