I'm new into eXist-db and I'm trying (with no luck) to get data from a collection I created under "apps", called "compositions", using Java/Groovy code.
Under apps/compositions collection, I put a couple of XMLs with this shape:
<version xmlns="http://ift.tt/1C3MWPL" xmlns:xsi="http://ift.tt/ra1lAU" xsi:type="ORIGINAL_VERSION">
...
<data xsi:type="COMPOSITION" archetype_node_id="openEHR-EHR-COMPOSITION.signos.v1">
<name>
<value>xxxxx</value>
</name>
...
</data>
</version>
I'm using XQJ to help me with the client side code. I tried to use a sample code (from here http://ift.tt/1y475zY and http://xqj.net/exist/) like:
XQDataSource xqs = new ExistXQDataSource();
xqs.setProperty("serverName", "localhost");
xqs.setProperty("port", "8080");
XQConnection conn = xqs.getConnection("user","pass");
XQExpression expr = conn.createExpression();
XQResultSequence result = expr.executeQuery(
"for $n in fn:collection('/db/apps/compositions')//data " +
"return fn:data($n/name/value)"); // execute an XQuery expression
// Process the result sequence iteratively
while (result.next()) {
// Print the current item in the sequence
System.out.println("Product name: " + result.getItemAsString(null));
}
// Free all resources created by the connection
conn.close();
And I expected to get the xxxxx texts from all the xmls under apps/compositions collection but I get no data without any exception.
Any ideas?
Thanks a lot!
BTW: I tried to find other ways of implementing a java client, but couldn't find a clear guideline or tutorial for beginners.
No comments:
Post a Comment