external variables
Sunday, 23 January 2011 · 4 messages · last reply 24 Jan 2011
IL
Imsieke, Gerrit, le-tex23 Jan 2011 17:36 #
I'm trying to pass a parameter to an xquery file whose first line reads: define variable $db as xs:string external
How may I invoke the BaseX client so that the param will be passed to the query?
Just saw in the 6.5 change log "[ADD] JAX-RX: bind external variables to query and run parameter". Does that mean that passing param is currently only available in the JAX-RX interface?
Maybe you can parse the command line client invocation such that everything after the options and after a xquery file name is considered as param=value pairs?
-Gerrit
CG
Christian Grün23 Jan 2011 19:22 #
Dear Gerrit,
currently, external variables are supported by our various language bindings (listed at http://docs.basex.org/wiki/Languages) and JAX-RX, but not on the command line. Your feature request looks quite reasonable, though, so I'll probably add a -b option, similar to the option -s for defining serialization parameters. A command line call will look sth. like that:
basex -bvar1=hello -bvar2=world query.xq
Hope this helps,
Christian
Quoted text · le-tex · 22 lines
On Sun, Jan 23, 2011 at 5:36 PM, Imsieke, Gerrit, le-tex <gerrit.imsieke at le-tex.de> wrote: > I'm trying to pass a parameter to an xquery file whose first line reads: > define variable $db as xs:string external > > How may I invoke the BaseX client so that the param will be passed to the > query? > > Just saw in the 6.5 change log "[ADD] JAX-RX: bind external variables to > query and run parameter". Does that mean that passing param is currently > only available in the JAX-RX interface? > > Maybe you can parse the command line client invocation such that everything > after the options and after a xquery file name is considered as param=value > pairs? > > -Gerrit > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
CG
Christian Grün24 Jan 2011 13:57 #
Gerrit,
I've now added a -b flag to the command-line options of BaseX Client and Standalone. This way, external variables can be bound to queries, which are either referenced as file, or specified via the -c or -q flags. Two examples:
basex -b a=1 query.xq
basexclient -b a=1 -q "declare variable $a external; $a"By defauls, the passed on values will be treated as strings. If the query specifies a data type, the passed on value will be cast to that type. Note that the value to be bound may not contain equality signs, commas, semi-colons or (depending on the OS) other characters that may be interpreted the wrong way. In other words, the integrated solution doesn't support all values that could be bound to variables. Similar restrictions apply to the GET method of JAX-RX, though.
Christian
Quoted text · Christian Grün · 40 lines
On Sun, Jan 23, 2011 at 7:22 PM, Christian Grün <christian.gruen at gmail.com> wrote: > Dear Gerrit, > > currently, external variables are supported by our various language > bindings (listed at http://docs.basex.org/wiki/Languages) and JAX-RX, > but not on the command line. Your feature request looks quite > reasonable, though, so I'll probably add a -b option, similar to the > option -s for defining serialization parameters. A command line call > will look sth. like that: > > basex -bvar1=hello -bvar2=world query.xq > > Hope this helps, > Christian > > > On Sun, Jan 23, 2011 at 5:36 PM, Imsieke, Gerrit, le-tex > <gerrit.imsieke at le-tex.de> wrote: >> I'm trying to pass a parameter to an xquery file whose first line reads: >> define variable $db as xs:string external >> >> How may I invoke the BaseX client so that the param will be passed to the >> query? >> >> Just saw in the 6.5 change log "[ADD] JAX-RX: bind external variables to >> query and run parameter". Does that mean that passing param is currently >> only available in the JAX-RX interface? >> >> Maybe you can parse the command line client invocation such that everything >> after the options and after a xquery file name is considered as param=value >> pairs? >> >> -Gerrit >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> >
CG
Christian Grün24 Jan 2011 14:05 #
Quoted text · Christian Grün · 5 lines
> Yesterday you sketched that multiple -b options > may be given if multiple params need to be passed. > Does your implementation > behave like that (multiple -b), or if just a single -b is permitted, how do > I separate multiple param/value pairs?
Exactly; more than one -b parameter can be specified. As an
alternative, several bindings can also be split by commas:
basex -b a=1,b=1 query.xq
Quoted text · Christian Grün · 83 lines
> On 24.01.2011 13:57, Christian Grün wrote: >> >> Gerrit, >> >> I've now added a -b flag to the command-line options of BaseX Client >> and Standalone. This way, external variables can be bound to queries, >> which are either referenced as file, or specified via the -c or -q >> flags. Two examples: >> >> basex -b a=1 query.xq >> basexclient -b a=1 -q "declare variable $a external; $a" >> >> By defauls, the passed on values will be treated as strings. If the >> query specifies a data type, the passed on value will be cast to that >> type. Note that the value to be bound may not contain equality signs, >> commas, semi-colons or (depending on the OS) other characters that may >> be interpreted the wrong way. In other words, the integrated solution >> doesn't support all values that could be bound to variables. Similar >> restrictions apply to the GET method of JAX-RX, though. >> >> Christian >> >> >> On Sun, Jan 23, 2011 at 7:22 PM, Christian Grün >> <christian.gruen at gmail.com> wrote: >>> >>> Dear Gerrit, >>> >>> currently, external variables are supported by our various language >>> bindings (listed at http://docs.basex.org/wiki/Languages) and JAX-RX, >>> but not on the command line. Your feature request looks quite >>> reasonable, though, so I'll probably add a -b option, similar to the >>> option -s for defining serialization parameters. A command line call >>> will look sth. like that: >>> >>> basex -bvar1=hello -bvar2=world query.xq >>> >>> Hope this helps, >>> Christian >>> >>> >>> On Sun, Jan 23, 2011 at 5:36 PM, Imsieke, Gerrit, le-tex >>> <gerrit.imsieke at le-tex.de> wrote: >>>> >>>> I'm trying to pass a parameter to an xquery file whose first line reads: >>>> define variable $db as xs:string external >>>> >>>> How may I invoke the BaseX client so that the param will be passed to >>>> the >>>> query? >>>> >>>> Just saw in the 6.5 change log "[ADD] JAX-RX: bind external variables to >>>> query and run parameter". Does that mean that passing param is currently >>>> only available in the JAX-RX interface? >>>> >>>> Maybe you can parse the command line client invocation such that >>>> everything >>>> after the options and after a xquery file name is considered as >>>> param=value >>>> pairs? >>>> >>>> -Gerrit >>>> _______________________________________________ >>>> BaseX-Talk mailing list >>>> BaseX-Talk at mailman.uni-konstanz.de >>>> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>>> >>> > > -- > Gerrit Imsieke > Geschäftsführer / Managing Director > le-tex publishing services GmbH > Weissenfelser Str. 84, 04229 Leipzig, Germany > Phone +49 341 355356 110, Fax +49 341 355356 510 > gerrit.imsieke at le-tex.de, http://www.le-tex.de > > Registergericht / Commercial Register: Amtsgericht Leipzig > Registernummer / Registration Number: HRB 24930 > > Geschäftsführer: Gerrit Imsieke, Svea Jelonek, > Thomas Schmidt, Dr. Reinhard Vöckler >
Written for BaseX 6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery