How can I bind an external variable to a sequence?
I see the syntax trick for escaping commas, but I still don't get a bound sequence.
I tried this:
import org.basex.core.*;
import org.basex.core.cmd.*;
import org.junit.*;
public class BindingTest {
String var = "$ids=";
String seq = "('a',,'b',,'c')";
String query = ""
+ "declare variable $ids external; "
+ "let $count := count($ids) "
+ "return if($count gt 1) then element ids { $ids } "
+ "else error(QName('urn:err', 'not_enough_ids'), xs:string($count)) "
;
/**
* test binding external variable to sequence
*/
@Test
public void test() {
try {
Context context = new Context();
new Set(Prop.BINDINGS, var + seq).execute(context);
String result = new XQuery(query).execute(context);
context.close();
System.out.println(result);
} catch(Exception e) {
System.err.println(e);
}
}
}
I expect to get <ids>...</ids> but instead I get the error. I'm using v7.5, Java 7u13.