|
top
|
 Subject: How to access to global variables Author: (Deleted User) Date: 26 Jun 2009 06:20 AM
|
Hi Kam,
when I was suggesting to use a command line, I was referring to the fact that Stylus Studio doesn't expose a UI to set variables that are defined in a module, so you have to manually set them.
In your case, as you are running DDXQ from a server application, you are already in control of how DDXQ is invoked, and can plug the appropriate code.
For instance, if you have a main module like
-----------
import module namespace p = "http://www.acmme.org" at "module.xquery";
p:concat($p:hello,$p:hello2)
-----------
that imports this module
-----------
module namespace p = "http://www.acmme.org";
declare variable $p:hello as xs:string := "Hello, World!";
declare variable $p:hello2 as xs:string external;
declare function p:concat($st1 as xs:string, $st2 as xs:string) as xs:string
{
if(string-length($st1) > string-length($st2)) then
concat($st1, $st2)
else
concat($st2, $st1)
};
-----------
and invoke the query using this Java code
xqExpr = xqconnection.prepareExpression(xqueryReader);
xqExpr.executeQuery().writeSequenceToResult(new StreamResult(outWriter));
you can set the $p:hello2 external variable by adding this line before the executeQuery call
tempXQE = bindParameter(xqconnection, xqExpr, new QName("http://www.acmme.org", "hello2"), "a");
Hope this helps,
Alberto
|
|
|
|