Alex Rivera | Logout

Can I declare a global variable in xquery in Marklogic Server?

Asked 2012-06-15T08:51:00.040
9

I want a global variable which I can use in my different .xqy pages. Can I declare such a variable in xquery in Marklogic Server ?

Edit
Report

1 Answer

1

You have a few options. If you need a global constant variable, the config.xqy method mentions in @Andrew Orlov's answer is great because you avoid any locking from concurrent access to a properties.xml file.

If you need a variable that can be mutated across a cluster of nodes, the property.xqy example linked by @wst appears to use globally assigned namespaces to embed a retrievable key and value. Pretty clever. However, I'm not sure how much this is meant for heavy levels of change.

The E-node specific variable from @Eric Bloch is good, but please also be aware that it will not survive a system restart.

I'd be interested to know how these all compare performance-wise.

answered 2012-06-15T23:47:09.597

Your Answer