question regarding element types in function definitions/XQuery

I know this has been answered in one way or another over the past year
or so, but I'm still having trouble understanding the specifications as
the language and semantic specs. don't seem to exactly agree, and the
publicly available issue resolution is somewhat unreadable.

If I define a function as follows:

define function foo($i as element my:elementdef) { 1 }

does this raise a static type error if I have not imported a schema
defining element my:elementdef ?

However, if I define a function as follows:

define function foo($i as element my:elementdef of type xs:integer) { 1
}

does this raise a static type error if I have not imported a schema
defining element my:elementdef?  Conversely, what if I have defined an
element my:elementdef?  Provided xs:integer is a subtype of the type of
the globally defined my:elementdef, is this acceptable?  Or, does this
signature imply that the argument need only have the element name
my:elementdef, with a type xs:integer, regardless of the existence of
my:elementdef as a global element definition?

	Thanks,
	-Todd

PS: Another difference between the language and semantic specifications
relates to untyped function arguments and function return values.  The
language spec has them as xs:anyType whereas the semantic spec has them
as item*.  Although the difference is subtle, I believe that item*
matches more values than xs:anyType.  (e.g.  (element foo, attribute
bar) matches item* but not xs:anyType, whose value space has all
attributes preceding all elements, assuming I'm correctly interpreting
3.2.4 in semantic spec.)

Received on Friday, 21 February 2003 11:01:04 UTC