W3C home > Mailing lists > Public > public-qt-comments@w3.org > May 2003

optional and required external variables

From: Per Bothner <per@bothner.com>
Date: Wed, 21 May 2003 17:21:02 -0700
To: public-qt-comments@w3.org
Message-id: <3ECC17EE.4010007@bothner.com>

4.6 in the XQuery spec says:
   If the variable definition includes the keyword external,
   a value must be provided for the variable by the external
   environment before the query can be evaluated.

This does not provide a mechanism for providing a default
value to an optional parameter.  Admittedly an implementation
can implement a convention, such as a missing parameter
resulting in an empty sequence.  However, the XSLT spec
does specify that parameters may be optional, and for
consistency the XQuery spec should do the same.
Here are two options that come to mind:

(1) Don't change the syntax.  However, if the type of the
variable (either the default of 'item*' or an explicit
TypeDeclaration) has an OccurrenceIndicator or '?' or '*',
then a missing parameter results in the empty sequence.
Otherwise a type error is raised.

(2) Use an explicit syntax.  I suggest:

define variable $VarName [as Type] external { default-expression }
define variable $VarName [as Type] external required

The former specifies that the parameter is optional and gives a
default value; the latter specifies that the parameter is required.

I think (2) is the better solution.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/
Received on Wednesday, 21 May 2003 20:19:54 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:14:24 GMT