Hi,

passing parameters to xquery dynamically can be done with the xquery java bindings.
So the parameter comes directly from your java class.

for example you can create a class like the following (i did create it in the org.basex package):

package org.basex;

public class Test {
  public Test() {
  }
  public static int calc(final int t) {
    return  t * t;
  }
}
and run a query like the following:

declare namespace test = "java:org.basex.Test";
for $i in 1 to 10 return test:calc(xs:int($i))

so the results are: 1 4 9 16 25 36 49 64 81 100

If you want to avoid static methods you can do it as follows:

class:
package org.basex;
public class Test {
  public Test() {
  }
  public int calc(final int t) {
    return  t * t;
  }
}

query:
declare namespace test = "java:org.basex.Test";
for $i in 1 to 10
let $t :=  test:new()
return test:calc($t, xs:int($i))

note you have to pass a created test-object to the calc-method then...

I hope this helps,
kind regards,
Andreas

Am 30.12.10 14:01, schrieb software developer:
Hi,

eXist DB offers this facility via HTTP related functions: http://en.wikibooks.org/wiki/XQuery/Checking_for_Required_Parameters

What I want to achieve is pass parameters to XQuery dynamically (not necessarily by using HTTP request parameters, although that appears to be one way of achieving this).  Is that possible in BaseX; if yes, how?

Thanks.
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk