Hi Kevin,
If you want to send data to both a server and a local instance, you
could have a look at our Session interface [1,2]. It’s fairly similar
to the externalized BaseXClient bindings, and it allows you to specify
an input stream for adding database resources.
Hope this helps,
Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/api/client/Session.java
[2] https://github.com/BaseXdb/basex/tree/master/basex-core/src/main/java/org/basex/api/client
On Thu, Dec 24, 2015 at 12:19 AM, Kevin S. Clarke <ksclarke@gmail.com> wrote:
> Hi Christian,
>
> I want to be able to use the existing commands (ADD for instance) regardless
> of whether the module is being accessed from the command line or as a part
> of a client/server architecture.
>
> In one case (that I've already written), I'm reading in an unsupported
> "binary" format and converting it into XML FDoc(s)/FElem(s) that can be
> returned from my module and used with the database module to write documents
> to the database. But, in the other case, I also want to be able to read my
> binary format and write XML directly to the database directly from my Java
> module (and then users of my module could use the BaseX database module to
> do further things with it from there).
>
> I see how to do ADDs from the command line and how to do it from the
> client/server API. I guess I'm just not sure how a module is supposed to go
> about this though (since it will be running from an XQuery that could be
> running from the command line or a client/server setup). Does it check to
> see the context in which it's running and then use one or the other method?
> I wouldn't want someone using my module in the client/server mode to have to
> input username/password again; I'd just want the permissions from the
> existing context to be used.
>
> Perhaps I'm interested in the streaming? What I'm doing, to be more
> specific, is reading in MARC (machine readable cataloging) records and
> converting them to MARCXML. Since some MARC records files will contain a
> large number of records, I was wanting to write them directly, one by one,
> to the database (where they could then be used by the db module). Is there
> a streaming interface that I should be looking at instead that would avoid
> having everything in memory at once?
>
> If it helps explain it any better, here is how I did it in exist-db. I'm
> just looking to do the same thing in the BaseX way now.
>
> https://github.com/ksclarke/freelib-marc4j-exist/blob/master/src/main/java/info/freelibrary/xquery/marc/ReadFromFile.java#L153
>
> Thanks for any pointers,
> Kevin
>
>
> On Wed, Dec 23, 2015 at 9:13 AM, Christian Grün <christian.gruen@gmail.com>
> wrote:
>>
>> Hi Kevin,
>>
>> There are numerous ways to add database to documents, so we’ll
>> probably need more information to answer your question:
>>
>> * Do you basically want to mirror the functionality of the existing
>> database commands [1] or functions [2]?
>> * Do you work with the client/server architecture of BaseX?
>> * Do you want to use input streams?
>>
>> Cheers,
>> Christian
>>
>> [1] http://docs.basex.org/wiki/Commands
>> [2] http://docs.basex.org/wiki/Database_Module
>>
>>
>> On Wed, Dec 23, 2015 at 12:03 AM, Kevin S. Clarke <ksclarke@gmail.com>
>> wrote:
>> > Hi,
>> >
>> > I'm writing a Java module that will do a couple of things, in addition
>> > to
>> > adding documents to a BaseX database. I've gotten the other things
>> > done,
>> > but I'm stuck a bit about how to add docs to the database from a module
>> > (I've seen the example that returns xml fragments that can be used from
>> > the
>> > xquery side). I see on http://docs.basex.org/wiki/Java_Examples that
>> > there
>> > are local/embedded and client-api ways to interact, but a module would
>> > want
>> > to be able to work in either situation. Are there any module examples
>> > that
>> > write to the database that someone would like to share (or just point me
>> > in
>> > the right direction)?
>> >
>> > Thanks,
>> > Kevin
>
>
>
>
> --
> "There are two kinds of people in this world: those who believe there are
> two kinds of people in this world and those who know better."