[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Setting global variables

Ronald Bourret rpbourret at rpbourret.com
Wed Oct 31 12:16:37 PST 2007


  Setting global variables
Hi, John,

Unfortunately, this does not solve my problem. The name of the document 
can vary, so I can't simply initialize a variable.

One possibility is to make the variable external to the library and then 
set it from the calling query. This would require an 
implementation-specific function -- I'm using Saxon -- and appears to 
violate the XQuery notion of not changing variable values.

One could make the argument that external variables already violate the 
notion of not changing variable values to some extent, and extending 
that capability to libraries is not unreasonable. On the other hand, one 
could also argue that libraries are already parameterized through 
function arguments.

-- Ron

John Snelson wrote:
> Hi Ronald,
> 
> There is no way to do what you're asking, since XQuery is a functional 
> language and variable values cannot be changed.
> 
> What's wrong with something like this:
> 
> declare variable $foo:listOfNames := fn:doc("mydoc.xml")//Name;
> 
> declare function foo:firstFunctionCalled(...)
> {
>   ...
> };
> 
> declare function foo:functionCalled MuchLater(...)
> {
>   ...
>   if ($name = $foo:listOfNames)
>   ...
> };
> 
> John



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.