- From: Jonathan Robie <jonathan.robie@datadirect.com>
- Date: Tue, 17 Aug 2004 09:16:42 -0400
- To: "Mark D. Anderson" <mda@discerning.com>
- CC: public-qt-comments@w3.org
Mark D. Anderson wrote: > 1. Section 4.12 of WD-xquery-20040723 indicates that a library module > can only declare variables in its own namespace, and that > unprefixed variables can only be declared in a main module. > > But what does this mean about using unprefixed variables in a > library module? > If a main module has: > > declare variable $mainvar = 'fred'; > import module foo = "http://whatever.org/modules/foo" at "foo.xq"; > > Should foo.xq allow: > > module namespace foo = "http://whatever.org/modules/foo"; > declare function foo:getmain() {$mainvar}; foo.xq has no way to import the main module. If you aren't a library module, you can't be imported. So there's no way for foo.xq to get access to $mainvar. foo.xq can only declare variables in its own namespace, and can only get access to variables in other modules by importing them - and these variables will be namespace qualified. I'm ignoring the word 'unprefixed' - the prefixes don't really matter, it is namespace qualification that is important. Earlier versions of the spec seemed to imply that the prefixes were what counts, but I hope we've got that consistently fixed now. > 2. I am similarly confused by section 4.11. > Should a library module be able to use a namespace declared > in a main module? > Is it legal for it to provide its own definition? > > An example main module might be: > > declare namespace bar = "http://whatever.org/namespaces/bar"; > import module foo = "http://whatever.org/modules/foo" at "foo.xq"; > > and foo.xq would then be: > > module namespace foo = "http://whatever.org/modules/foo"; > (:declare namespace bar = "http://whatever.org/namespaces/bar";:) > declare function foo:getbar() {<bar:root/>}; A library module has no idea what has or has not been declared in a main module, and you can compile a library module separately in some implementations. So yes, there's no problem with declaring the same namespace in a main module and a library module. > 3. In section .43, I'm unclear as to whether the "local" prefix > is legal in a library module. It says: > > In order to allow main modules to declare functions for local use > within the module > without defining a new namespace, XQuery predefines the namespace > prefix local to > the namespace http://www.w3.org/2004/07/xquery-local-functions, and > reserves this namespace for use in defining local functions. > > I hope this doesn't mean that it is impossible/illegal to define > local functions in a library module. Local functions (and variables) are obviously useful, but we don't have them in XQuery 1.0. Since every function and variable declared in a module must be qualified by the module's target namespace, you can't use the local prefix, which would put it in a different namespace. You could try asking us to consider local functions and variables as a new feature, but this has been considered several times and has always failed so far. I hope this is helpful and answers your questions. Jonathan
Received on Tuesday, 17 August 2004 13:17:15 UTC