David,

        I'm sure someone will correct me if I'm wrong, but I don't
believe it's possible to pass an eternal variable in through an HTTP app
server directly.
        That said you could write a very simple XQuery module to invoke
your module with the external variables. I'm going to assume that the
code you provided was in a module called my-mod.xqy and that the code
I'm providing below is in a module called my-invoker.xqy:

let $x := xdmp:get-request-field("x")
xdmp:invoke("my-mod.xqy", (xs:QName("x"), $x))

Then you can just access this module which will in turn invoke your code
and pass in the value of x in the query string. Just to be sure I'm
making myself clear:

my-invoker.xqy?x=test

Will result in your module being invoked, with the variable x set to
"test", which will then return "test".

Hopefully this will help.

-fs

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David
Sewell
Sent: Friday, January 11, 2008 1:02 PM
To: General XQZone Discussion
Subject: [MarkLogic Dev General] External variables and HTTP app server

Is there any way to pass an external variable to the main query when it
is running via an HTTP app server? I.e., making it possible to run

   define variable $x as xs:string external

   $x

without throwing an "undefined external variable error"?

(I know I can use HTTP request fields to pass "external variables". But
I have some code I'd like to be able to run without modification via
XDBC, which returns () for xdmp:get-request-field(), etc. So is there
any  mechanism of passing a run-time external variable to the
server that works the same way under either HTTP or XDBC app servers?)

David

--
David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 801079, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: [EMAIL PROTECTED]   Tel: +1 434 924 9973
Web: http://rotunda.upress.virginia.edu/
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to