eXist-db を初めて使用します。Java/Groovy を使用して、作成したコレクションからデータを取得しようとしています (運が悪い) /db/apps/compositions
。
以下/db/apps/compositions
に、次のような XML ドキュメントをいくつか示します。
<version xmlns="http://schemas.openehr.org/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ORIGINAL_VERSION">
...
<data xsi:type="COMPOSITION" archetype_node_id="openEHR-EHR-COMPOSITION.signos.v1">
<name>
<value>xxxxx</value>
</name>
...
</data>
</version>
クライアント側のコードで XQJ API を使用しています。サンプル コードを適合させようとしました ( http://en.wikipedia.org/wiki/XQuery_API_for_Javaおよびhttp://xqj.net/exist/から):
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();
コレクション内のすべての XML ドキュメントから xxxxx テキストを取得することを期待していましたが、/db/apps/compositions
結果が得られず、例外もスローされません。
何か案は?
どうもありがとう!
ところで: Java クライアントを実装する他の方法を見つけようとしましたが、初心者向けの明確なガイドラインやチュートリアルを見つけることができませんでした。