Hi,

Same scenario is for s9api also,
I tried below example and go through spec.

                Processor proc = new Processor(false);
                XQueryCompiler comp = proc.newXQueryCompiler();
//                int[] no = {10,20,30};
                 int no = 10
                XQueryExecutable exp = comp.compile(
                        "declare variable $n external;  ave($n)");
                XQueryEvaluator qe = exp.load();
                qe.setExternalVariable(new QName("n"), new XdmAtomicValue(no));
                XdmValue result = qe.evaluate();
             
                int total = 0;
                for (XdmItem item: result)  {
                    total += ((XdmAtomicValue)item).getLongValue();
                }
                System.out.println("Total: " + total);


I am able to bind a single value for item, but for array / list, I didn't find any option.
I also check the specs but under XdmAtomicValue class there isn't any constructor available to which I can pass array / list.

please guide me

Thanks and Regards,
Kunal


On Mon, Apr 29, 2013 at 8:51 PM, Michael Kay <mike@saxonica.com> wrote:
I'm afraid I'm only answering this by reading the XQJ spec; I never use XQJ myself so I'm no great expert.

You have to use xqeTemp.bindSequence(). Which means you have to construct an XQSequence object. The Saxon implementations of this interface have no public constructors, and the Saxon implementation of bindSequence() won't accept an implementation of XQSequence other than the ones it knows about. So I think the only option is to get the value as the result of another query.

XQJ is full of limitations like this and unless you have very good reasons for wanting a portable API, I would recommend using s9api instead.

Michael Kay
Saxonica


On 29 Apr 2013, at 14:38, Kunal Chauhan wrote:


Hi,

how can I bind multiple value to a variable ?

Suppose, I am declaring an external variable v1 and want to pass list / array of value (10,20,30) how can I achieve this ?

Example :

 int v1 = 5;
             SaxonXQExpression xqeTemp = (SaxonXQExpression)XQueryConnection.getConnection().createExpression();
             xqeTemp.bindObject(new QName("v1"), Integer.parseInt(v1),null);


             XQResultSequence xqsTemp =  xqeTemp.executeQuery("declare variable $v1 external; \n" +   
                                                                 "return $v1 + 5");
             System.out.println(" Result : "+xqsTemp.getSequenceAsString(null));


Here, in above example I bind variable v1 with the value 5 and do some operation in query. Now instead of single value I wants to bind multiple value with variable v1. So, how can I do this ?

please guide me.

Thanks and Regards,
--
Kunal Chauhan
[+918655517141]
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help



--
Kunal Chauhan
mail4ck@gmail.com
[+918655517141]
[+919904983614]