Yes, that worked—but I think I solved the problem (I wouldn’t have seen it except for trying this, though). And of course it is trivial:
I had originally:
session.execute(“SET BINDINGS journal_id=‘hc2’”)
because I was following the example in the wiki. Changing that to:
session.execute(“SET BINDINGS journal_id=hc2”)
worked. Of course, assigning a variable and composing the command string by concatenation also works, so I shot myself in the foot by thinking I could just use a fixed string to test.
So thanks for the advice—it helped.
Bryan Cholfin Associate Editor for Digital Projects and Metadata Harvard University Press 617.496.9116 79 Garden Street | Cambridge, MA 02138-1400 www.hup.harvard.edu http://www.hup.harvard.edu/
On 11/17/15, 2:29 PM, "Christian Grün" christian.gruen@gmail.com wrote:
No—trace doesn’t seem to send anything to stderr. (I even forced a couple of errors just to make sure stderr was going where I thought it was).
This would indicate that the predicate is never evaluated.
How does your full query look like? Do you get output when running the query on command-line?..
basex -b ext_variable=xyz query.xq
Bryan Cholfin Associate Editor for Digital Projects and Metadata Harvard University Press 617.496.9116 79 Garden Street | Cambridge, MA 02138-1400 www.hup.harvard.edu http://www.hup.harvard.edu/
On 11/17/15, 1:59 PM, "Christian Grün" christian.gruen@gmail.com wrote:
I get this: [...]
This looks like the output that’s stored in the database logs, while trace output is written to STDERR (not STDOUT, as I wrote in my last response, sorry). Do you see anything there?
13:50:53.282 127.0.0.1:39813 admin REQUEST SET BINDINGS journal_id='hc2' 1.02 ms 13:50:53.282 127.0.0.1:39813 admin OK BINDINGS: journal_id='hc2' 0.11 ms 13:50:53.284 127.0.0.1:39813 admin REQUEST RUN /home/bryan/basex/webapp/waldo/waldotext.xqm 1.86 ms 13:50:53.287 127.0.0.1:39813 admin OK Query "waldotext.xqm" executed in 3.2 ms. 3.63 ms 13:50:53.288 127.0.0.1:39813 admin REQUEST EXIT 0.16 ms 13:50:53.288 127.0.0.1:39813 admin OK 0.09 ms
When I run the module from the gui and set the variable manually, it works as I expect.
Bryan Cholfin Associate Editor for Digital Projects and Metadata Harvard University Press 617.496.9116 79 Garden Street | Cambridge, MA 02138-1400 www.hup.harvard.edu http://www.hup.harvard.edu/
On 11/17/15, 1:19 PM, "Christian Grün" christian.gruen@gmail.com wrote:
declare variable $ext_variable as xs:string external; for $div in collection(Œwaldo¹)//div[@xml:id=$ext_variable]
What is output on server STDOUT if you trace the variable?..
declare variable $ext_variable as xs:string external; for $div in collection(Œwaldo¹)//div[@xml:id=trace($ext_variable)]
I get nothing. And yet I¹ve been able to return the variable itself from the module and check its type, and use it in a let assignment. So I can see that the module is receiving the value I send, it just isn¹t matching for some reason.
Bryan Cholfin
Associate Editor for Digital Projects and Metadata Harvard University Press 617.496.9116 79 Garden Street | Cambridge, MA 02138-1400 www.hup.harvard.edu
From: Etanchaud Fabrice Fabrice.Etanchaud@horanet.com Date: Tuesday, November 17, 2015 at 4:08 AM To: "Cholfin, Bryan" bryan_cholfin@harvard.edu, "basex-talk@mailman.uni-konstanz.de" basex-talk@mailman.uni-konstanz.de Subject: RE: [basex-talk] sending variables to xquery module via client api (python)
Hi Bryan,
Could http://docs.basex.org/wiki/Options#BINDINGSgive you a solution ?
Best regards,
Fabrice
De : basex-talk-bounces@mailman.uni-konstanz.de [mailto:basex-talk-bounces@mailman.uni-konstanz.de] De la part de Cholfin, Bryan Envoyé : lundi 16 novembre 2015 23:08 À : basex-talk@mailman.uni-konstanz.de Objet : [basex-talk] sending variables to xquery module via client api (python)
Hi‹
Hoping someone can help me with this. I¹m trying to write a python script that calls an xquery module in the database. It seems to be pretty easy to use a line such as:
session.execute(³run gettext.xqm²)
and get back the response I want. What I want to do is pass a bound variable to the module. The client api has a provision to bind a variable to a query object, but I¹m not making a query object. I¹m simply executing the stored query. I don¹t find anything in the documentation to suggest that a variable can be added to the run command this way.
Bryan Cholfin
Associate Editor for Digital Projects and Metadata Harvard University Press 617.496.9116 79 Garden Street | Cambridge, MA 02138-1400 www.hup.harvard.edu