XMLResource res = (XMLResource)col.createResource("test.xml", "XMLResource");
res.setContent(data);
col.storeResource(res);
// get query-service
XPathQueryServiceImpl service =
(XPathQueryServiceImpl) col.getService( "XPathQueryService", "1.0" );
// set pretty-printing on
service.setProperty( OutputKeys.INDENT, "yes" );
service.setProperty( OutputKeys.ENCODING, "UTF-8" );
// execute queries
ResourceSet set=null;
System.out.println();
System.out.println("Query 1");
System.out.println("=======");
set = service.query("/book/chapter");
res = (XMLResource) set.getResource(0);
System.out.println(res.getContent());
System.out.println();
System.out.println("Query 2");
System.out.println("=======");
set = service.query(res, "title");
res = (XMLResource) set.getResource(0);
System.out.println(res.getContent());
}