public boolean searchSecQuery() throws XQException { String query = "declare default element namespace \"http://tpox-benchmark.com/security\";\n" + "for $sec in fn:collection(\"CLN_Security\")/s:Security\n" + "where $sec[SecurityInformation/*/Sector = 'Technology' and PE[. >= xs:decimal('25') and . < xs:decimal('28.0')] and Yield > xs:decimal('0')]\n" + "return <Security>\n" + "\t{$sec/Symbol}\n" + "\t{$sec/Name}\n" + "\t{$sec/SecurityType}\n" + "\t{$sec/SecurityInformation//Sector}\n" + "\t{$sec/PE}\n" + "\t{$sec/Yield}\n" + "</Security>"; XQExpression xqe = xqc.createExpression(); XQResultSequence xqs = xqe.executeQuery(query); int cnt = 0; while (xqs.next()) { cnt++; } System.out.println("Got " + cnt + " results"); return cnt > 0; }
public boolean searchSecQuery() throws XQException { String query = "declare default element namespace \"http://tpox-benchmark.com/security\";\n" + "for $sec in fn:collection(\"/{http://tpox-benchmark.com/security}Security\")/Security\n" + "where $sec[SecurityInformation/*/Sector = 'Technology' and PE[. >= xs:decimal('25') and . < xs:decimal('28.0')] and Yield > xs:decimal('0')]\n" + "return <Security>\n" + "\t{$sec/Symbol}\n" + "\t{$sec/Name}\n" + "\t{$sec/SecurityType}\n" + "\t{$sec/SecurityInformation//Sector}\n" + "\t{$sec/PE}\n" + "\t{$sec/Yield}\n" + "</Security>"; XQExpression xqe = xqc.createExpression(); XQResultSequence xqs = xqe.executeQuery(query); int cnt = 0; while (xqs.next()) { cnt++; } System.out.println("Got " + cnt + " results"); return cnt > 0; }
@Override public String queryDocumentByUri(String uri) throws XQException { String query = "for $doc in fn:doc(\"" + uri + "\")\n" + "return $doc\n"; XQExpression xqe = xqConn.createExpression(); XQResultSequence xqs = xqe.executeQuery(query); String result = null; if (xqs.next()) { result = xqs.getItemAsString(null); } return result; }
public void removeSecCommand(long docId) throws XQException { XQExpression xqe = xqc.createExpression(); xqe.bindLong(new QName("docId"), docId, xqc.createAtomicType(XQItemType.XQBASETYPE_LONG)); xqe.executeCommand("removeDocument($docId)"); xqe.close(); } /*
@Override public String queryDocumentFromCollection() throws XQException { String query = "for $doc in fn:collection()\n" + "return $doc\n"; XQExpression xqe = xqConn.createExpression(); XQResultSequence xqs = xqe.executeQuery(query); String result = null; if (xqs.next()) { result = xqs.getItemAsString(null); } return result; }
public void removeSecCommand(long docId) throws XQException { XQExpression xqe = xqc.createExpression(); xqe.bindLong(new QName("docId"), docId, xqc.createAtomicType(XQItemType.XQBASETYPE_LONG)); xqe.executeCommand("removeDocument($docId)"); xqe.close(); } /*
public void storeSecCommand() throws XQException { String dName = "..\\..\\etc\\samples\\tpox\\"; String xml; try { xml = readTextFile(dName + "security5621.xml"); } catch (IOException ex) { throw new XQException(ex.getMessage()); } XQExpression xqe = xqc.createExpression(); xqe.bindString(new QName("doc"), xml, xqc.createAtomicType(XQItemType.XQBASETYPE_STRING)); xqe.executeCommand("storeDocument($doc)"); // todo: get XDMDocument back somehow.. // XDMDocument doc = (XDMDocument) ... xqe.close(); }
public void storeSecCommand() throws XQException { String dName = "..\\..\\etc\\samples\\tpox\\"; String xml; try { xml = readTextFile(dName + "security5621.xml"); } catch (IOException ex) { throw new XQException(ex.getMessage()); } XQExpression xqe = xqc.createExpression(); xqe.bindString(new QName("doc"), xml, xqc.createAtomicType(XQItemType.XQBASETYPE_STRING)); xqe.executeCommand("storeDocument($doc)"); // todo: get XDMDocument back somehow.. // XDMDocument doc = (XDMDocument) ... xqe.close(); }
@Override protected int execCommand(String query, Map<String, Parameter> params) throws XQException { XQExpression xqe = getConnection().createExpression(); bindParams(params, xqe); xqe.executeCommand(query); // do next somehow! xqe.close(); return 1; }
props2Context(schemaManager.getEntity().getProperties(), ctx); props2Context(props, ctx); XQExpression xqExp = xqConn.createExpression(ctx); XQResultSequence xqSec = xqExp.executeQuery(query); result = extractResult(xqSec, props);