ArrayList<Acte> getActes( Unmarshaller jaxbUnmarshaller, XQPreparedExpression expr, XQConnection conn) { ArrayList<Acte> songs = new ArrayList<Acte>(); try { XQResultSequence rs = expr.executeQuery(); while (rs.next()) { XQItem item = rs.getItem(); Acte acte = (Acte) jaxbUnmarshaller.unmarshal(item.getNode()); songs.add(acte); System.out.print(acte + "\n"); } } catch (Exception e) { // log.log(Level.SEVERE, e.getMessage()); } finally { close(expr, conn); } return songs; }
// @Test public void staticFileTest() throws ClassNotFoundException, IllegalAccessException, InstantiationException, XQException, FileNotFoundException { XQPreparedExpression expr; XQConnection conn; // TODO Change local path file InputStream testFile = new FileInputStream(testXmlRoute); String xqueryString = " declare variable $doc external;\n" + "for $x in $doc return $x//acte/nom/text()"; XQDataSource xqds = (XQDataSource) Class.forName("net.sf.saxon.xqj.SaxonXQDataSource").newInstance(); conn = xqds.getConnection(); expr = conn.prepareExpression(xqueryString); expr.bindDocument(new javax.xml.namespace.QName("doc"), testFile, null, null); XQResultSequence rs = expr.executeQuery(); System.out.println("test:"); while (rs.next()) System.out.println(rs.getItemAsString(null)); assertNotNull(rs); conn.close(); }