Hi,

I did some first steps with BaseX, but unfortunately I was not very
successful.

I have a really large XML file which does not fit into memory, and I
would like to navigate it as a DOM. My hope was that I could store it as
a BaseX database, retrieve the root element as a org.w3c.dom.Node, and
then start navigating down and up the DOM as needed without having to
have the whole stuff in memory.

I tried something like this:

    QueryProcessor processor = new QueryProcessor("doc('catalog')/*",
    context);
    Iter iter = processor.iter();
    Item item = iter.next();
    Object node = item.toJava();

According to the debugger the item variable indeed denoted my root
element. However, when calling item.toJava() not only that very node was
returned. Instead BaseX obviously tried to retrieve the whole DOM –
which was just the very thing I wanted to avoid.

Am I doing something wrong here? Or is this an unforeseen use case?

By the way, I also had trouble getting any result at all. Only with
"doc('catalog')/*" I got an item that was not null. When I tried to
retrieve all elements named "article" using "doc('catalog')//article"
the item was null. I also tried the item.iter() in order to find a
node's children. However, it turned out that item().iter().next() == item.

And I had quite a tough time fiddling around with the documentation and
with the JavaDoc. While the documentation puts a lot of effort into
XQuery, it remains unclear to some extend how to do some basic stuff
with BaseX programmatically. This is a hurdle for the BaseX beginner.
Some more Java examples and explanations would be nice showing how to
connect to the database, submit a query and process the result.
Currently the examples show only how to dump a query result to
System.out. It would be interesting to learn about processing it further
– see my troubles with Iter.

-- 

Best regards
Rainer Klute


_______________________________________________
BaseX-Talk mailing list
BaseX-Talk@mailman.uni-konstanz.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk

Reply via email to