|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] Local namespaceMartin Probst mail at martin-probst.comFri Sep 11 16:02:13 PDT 2009
With a big caveat as I have not been involved in any of this, just how it seems to me. > From what I can see in the XQuery 1.0 REC, the "local" namespace > is aimed to be used only in a main module, and only to locally > define functions (not variables.) I think this simply came from the problem that functions without namespaces, which were allowed in an earlier draft, can collide with the built in functions or type names, so it was decided to require a namespace for all user defined functions. To make that a bit easier, we now have the local: namespace predeclared. This does not apply to variables as they don't share the same symbol space as functions, i.e. their names don't collide. > This is a bit surprising to me, > as I thought we could define both local:* functions & variables, > both in main and library modules... Indeed, you may not define functions or variables in modules that don't have the same namespace URI as the module: "The name of every variable and function declared in a library module must have a namespace URI that is the same as the target namespace of the module; otherwise a static error is raised [err:XQST0048]." Why that must be, I have never understood. It doesn't save the user from hard-to-find typo errors errors as you'd always declare the namespace prefix while declaring the module namespace, and then use that prefix. And it (IMHO) actively acts against modularization, as local variables or functions are highly desirable. In X-Hive / xDB, we have never followed that spec rule and allowed local functions/variables in modules, those are simply not exported to importing modules. I have also never really understood why it must be possible to have one module with one target namespace split over multiple files; I think Java has shown that the forced one-to-one relationship between conceptual name (class) and file (.java) is a good thing. Martin
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






