本文整理了Java中javax.xml.xquery.XQConnection.createExpression()
方法的一些代码示例,展示了XQConnection.createExpression()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XQConnection.createExpression()
方法的具体详情如下:
包路径:javax.xml.xquery.XQConnection
类名称:XQConnection
方法名:createExpression
[英]Creates a new XQExpression
object that can be used to perform execute immediate operations with XQuery expressions. The properties of the connection's default XQStaticContext
are copied to the returned XQExpression
.
[中]创建一个新的XQExpression
对象,可用于使用XQuery表达式执行即时操作。连接的默认属性XQStaticContext
将复制到返回的XQExpression
。
代码示例来源:origin: dsukhoroslov/bagri
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;
}
代码示例来源:origin: dsukhoroslov/bagri
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;
}
代码示例来源:origin: dsukhoroslov/bagri
@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;
}
代码示例来源:origin: dsukhoroslov/bagri
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();
}
/*
代码示例来源:origin: dsukhoroslov/bagri
@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;
}
代码示例来源:origin: dsukhoroslov/bagri
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();
}
/*
代码示例来源:origin: dsukhoroslov/bagri
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();
}
代码示例来源:origin: dsukhoroslov/bagri
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();
}
代码示例来源:origin: dsukhoroslov/bagri
@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;
}
代码示例来源:origin: dsukhoroslov/bagri
props2Context(schemaManager.getEntity().getProperties(), ctx);
props2Context(props, ctx);
XQExpression xqExp = xqConn.createExpression(ctx);
XQResultSequence xqSec = xqExp.executeQuery(query);
result = extractResult(xqSec, props);
内容来源于网络,如有侵权,请联系作者删除!