Hi Godmar,
to use iteration as in [1] with
while(query.more()) { System.out.print(query.next()); }
could help your issue. As I am not sure about the XPath semantics this could involve rewriting your Expression to a for/let loop to really get results one at a time.
Hope this helps, feel free to ask more.
Kind regards Michael
[1] https://svn.uni-konstanz.de/dbis/basex/trunk/api/etc/java/QueryExample.java
Am 19.08.2010 um 06:39 schrieb Godmar Back:
Hi,
when I use the client/server interface and run a query that returns multiple nodes, BaseX appears to return the results concatenated (and, somewhat oddly, with interspersed newlines).
For instance,
xquery declare namespace atom='http://www.w3.org/2005/Atom'; doc('myfeed')//atom:title
returns:
<title xmlns="http://www.w3.org/2005/Atom">First Title</title> <title xmlns="http://www.w3.org/2005/Atom">Second Title</title> <title xmlns="http://www.w3.org/2005/Atom">Third Title</title> ....
Does anybody happen to know how to parse those into separate XML documents in Java? (Short of preprocessing the XML to find the matching end tag for each element?) For background, classes such as javax.xml.parsers.DocumentBuilder can only parse one document at a time, and throw an error if the input source contains multiple documents/fragments.
Alternatively, would it make sense for BaseX to support returning results one by one (perhaps using a cursor approach) to ease the client's task of parsing the returned XML?