On 03/14/2012 08:08 PM, Christian GrĂ¼n wrote:
Right now, I'm aware of two ways to set the context item via the native protocol:
Here are some other alternatives (...not sure what you mean with the "native protocol"?):
By "native protocol", I was referring to the protocol documented at http://docs.basex.org/wiki/Server_Protocol#Transfer_Protocol, ie. operating with a server over-the-wire.
-- If you are using the command-line, you can also use the "-i" flag to bind documents or databases to the context.
I see that basexclient's -i uses the CHECK command over-the-wire to ask the server to open the named file as a database. Unfortunately, I'm looking to provide content over-the-wire, rather than being able to simply pass a location.
-- If you are working more low level, you can directly bind items to the QueryProcessor [1]
...which would be perfect if my usage were embedded. That said, this is actually very compelling -- if only I knew the over-the-wire equivalent to proc.context().
-- If you are using REST, you can use the Context parameter (e.g., the rest:context element) to bind items to the context [2]
The REST interface is what I've been using historically; I'm currently in the process of porting my code to work without it.
(2) Use the "CS" ["Context Set"] command
- Disadvantage: Requires a database to be open (why?)
This command works similar to other database commands, which refer to the currently opened database instance.
The "xquery" command, for instance, can be run without a currently opened database instance -- if run with a query which doesn't refer to the context, it succeeds without such a context.
What's the way you would prefer?
Hopefully something exists already. What I would consider ideal would be an equivalent to ADD (including respecting the PARSER option) which sets the context item rather than storing to the database.
Christian
[1] https://github.com/BaseXdb/basex-examples/blob/master/src/main/java/org/base... [2] http://docs.basex.org/wiki/REST