Re: Variable Declaration in Query Prolog

> Note that parameterizing namespace and schema declarations basically
> means that you cannot compile the functions (since the type information
> becomes dynamic). This is not something I need in a v1.0 standard or
> implementation.
>
agree but this is only on the assumption that the schema remains static
wrt to the given namespace; hard when the schema can potentially
have deep dependencies and requires to remain static for the
lifetime of the compiled function. Quite the converse, a 
compiled function's integrity is perhaps better assured if 
namespace and schema are parameterised (via prefixes, say) 
and dependency on type components be factored out into the 
evaluation context.

Variable typing is however a core issue and I feel that we need to
get off on the right footing for v1.0.

   Variable ::= Datatype? "$" QName

and allow variable declaration in the query prolog,
[2] QueryProlog ::= (NamespaceDecl
                                |  DefaultNamespaceDecl
                                |  SchemaImport)* FunctionDefn* Variable*

and allow variable assignment,

VariableAssignment ::= Variable ColonEquals Expr

[4] Expr ::= SortExpr 
      |  ....
      |  PathExpr 
      |  VariableAssignement

then we can have our construct such as
xs:string $x = "world"
<hello>{$x}</hello>

rather than
Let $x := "world"
return <hello>{$x}</hello>

and we can do this,
xs:string $userDatabase = "BusinessBooks.xml"

Let $x := document($userDatabase)//book
return ....

then our previous discussion on "environment variable" can
materialise if the QueryProlog changes to,

[2] QueryProlog ::= (NamespaceDecl
                                |  DefaultNamespaceDecl
                                |  SchemaImport)* FunctionDefn* Expr*

and even better still, completely defunct QueryProlog and
put its clauses into 

[4] Expr :: = NamespaceDecl
                   | DefaultNamespaceDecl
                   | SchemaImport
                   | FunctionDefn
                   | SortExpr
                   | ....

getting really far fetch huh ? Anyway, will file a short comment note 
to WG.

best regards,
Kuan Hui

Received on Thursday, 7 February 2002 22:05:12 UTC