本文整理汇总了Java中javax.xml.xquery.XQPreparedExpression类的典型用法代码示例。如果您正苦于以下问题:Java XQPreparedExpression类的具体用法?Java XQPreparedExpression怎么用?Java XQPreparedExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XQPreparedExpression类属于javax.xml.xquery包,在下文中一共展示了XQPreparedExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseQuery
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
@ManagedOperation(description="Parse XQuery. Return array of parameter names, if any")
@ManagedOperationParameters({
@ManagedOperationParameter(name = "query", description = "A query request provided in XQuery syntax"),
@ManagedOperationParameter(name = "props", description = "Query processing properties")})
public String[] parseQuery(String query, Properties props) {
XQPreparedExpression xqpExp = null;
try {
XQStaticContext ctx = xqConn.getStaticContext();
props2Context(schemaManager.getEntity().getProperties(), ctx);
props2Context(props, ctx);
xqpExp = xqConn.prepareExpression(query, ctx);
QName[] vars = xqpExp.getAllExternalVariables();
String[] result = null;
if (vars != null) {
result = new String[vars.length];
for (int i=0; i < vars.length; i++) {
result[i] = vars[i].toString();
}
}
xqpExp.close();
return result;
} catch (XQException ex) {
logger.error("parseQuery.error", ex);
throw new RuntimeException(ex.getMessage());
}
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:27,代码来源:QueryManagement.java
示例2: runPriceQuery
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
public boolean runPriceQuery(String symbol) throws XQException {
String query = "declare namespace s=\"http://tpox-benchmark.com/security\";\n" +
"declare variable $sym external;\n" +
"for $sec in fn:collection(\"CLN_Security\")/s:Security\n" +
"where $sec/s:Symbol=$sym\n" +
"return\n" +
"\t<print>The open price of the security \"{$sec/s:Name/text()}\" is {$sec/s:Price/s:PriceToday/s:Open/text()} dollars</print>\n";
XQPreparedExpression xqpe = xqc.prepareExpression(query);
xqpe.bindString(new QName("sym"), symbol, null); //IBM; VFINX; PTTAX
XQResultSequence xqs = xqpe.executeQuery();
boolean found = false;
while (xqs.next()) {
System.out.println(xqs.getItemAsString(null));
found = true;
}
return found;
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:20,代码来源:ClientApp.java
示例3: runSecQuery
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
public boolean runSecQuery(String symbol) throws XQException {
String query = "declare namespace s=\"http://tpox-benchmark.com/security\";\n" +
"declare variable $sym external;\n" +
"for $sec in fn:collection(\"CLN_Security\")/s:Security\n" +
"where $sec/s:Symbol=$sym\n" +
"return $sec\n";
XQPreparedExpression xqpe = xqc.prepareExpression(query);
xqpe.bindString(new QName("sym"), symbol, null);
XQResultSequence xqs = xqpe.executeQuery();
boolean found = false;
while (xqs.next()) {
System.out.println(xqs.getItemAsString(null));
found = true;
}
return found;
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:19,代码来源:ClientApp.java
示例4: readDocument
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
@Override
public String readDocument(String uri) throws XQException {
String query = "declare namespace bgdb=\"http://bagridb.com/bdb\";\n" +
"declare variable $uri external;\n" +
"let $doc := bgdb:get-document-content($uri)\n" +
"return $doc\n";
XQPreparedExpression xqpe = xqConn.prepareExpression(query);
xqpe.bindString(new QName("uri"), uri, xqConn.createAtomicType(XQItemType.XQBASETYPE_ANYURI));
XQResultSequence xqs = xqpe.executeQuery();
String result = null;
if (xqs.next()) {
result = xqs.getItemAsString(null);
}
return result;
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:18,代码来源:XQJClientApp.java
示例5: deleteDocument
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
@Override
public void deleteDocument(String uri) throws XQException {
String query = "declare namespace bgdb=\"http://bagridb.com/bdb\";\n" +
"declare variable $uri external;\n" +
"let $uri := bgdb:remove-document($uri)\n" +
"return $uri\n";
XQPreparedExpression xqpe = xqConn.prepareExpression(query);
xqpe.bindString(new QName("uri"), uri, xqConn.createAtomicType(XQItemType.XQBASETYPE_ANYURI));
XQSequence xqs = xqpe.executeQuery();
String result = null;
try {
if (xqs.next()) {
result = xqs.getAtomicValue();
}
if (!uri.equals(result)) {
throw new XQException("got no result from bgdb:remove-document function");
}
} finally {
xqpe.close();
xqs.close();
}
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:25,代码来源:XQJClientApp.java
示例6: runPriceQuery
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
public boolean runPriceQuery() throws XQException {
String query = "declare namespace s=\"http://tpox-benchmark.com/security\";\n" +
"declare variable $sym external;\n" +
"for $sec in fn:collection(\"/{http://tpox-benchmark.com/security}Security\")/s:Security\n" +
"where $sec/s:Symbol=$sym\n" + //'IBM'\n" +
"return\n" +
"\t<print>The open price of the security \"{$sec/s:Name/text()}\" is {$sec/s:Price/s:PriceToday/s:Open/text()} dollars</print>\n";
XQPreparedExpression xqpe = xqc.prepareExpression(query);
xqpe.bindString(new QName("sym"), "IBM", null); //IBM; VFINX; PTTAX
XQResultSequence xqs = xqpe.executeQuery();
boolean found = false;
while (xqs.next()) {
System.out.println(xqs.getItemAsString(null));
found = true;
}
return found;
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:20,代码来源:EmbeddedApp.java
示例7: runSecQuery
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
public boolean runSecQuery() throws XQException {
String query = "declare namespace s=\"http://tpox-benchmark.com/security\";\n" +
"declare variable $sym external;\n" +
"for $sec in fn:collection(\"/{http://tpox-benchmark.com/security}Security\")/s:Security\n" +
"where $sec/s:Symbol=$sym\n" + //'IBM'\n" +
"return $sec\n";
XQPreparedExpression xqpe = xqc.prepareExpression(query);
xqpe.bindString(new QName("sym"), "IBM", null);
XQResultSequence xqs = xqpe.executeQuery();
boolean found = false;
while (xqs.next()) {
System.out.println(xqs.getItemAsString(null));
found = true;
}
return found;
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:19,代码来源:EmbeddedApp.java
示例8: execQuery
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
@Override
protected int execQuery(String query, Map<String, Parameter> params) throws XQException {
XQPreparedExpression xqpe = getConnection().prepareExpression(query);
bindParams(params, xqpe);
XQResultSequence xqs = xqpe.executeQuery();
int cnt = 0;
if (fetchSize > 0) {
while (xqs.next() && cnt < fetchSize) {
cnt++;
}
} else {
while (xqs.next()) {
cnt++;
}
}
//xqs.close(); will be closed at next line
xqpe.close();
return cnt;
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:21,代码来源:BagriXQJPlugin.java
示例9: testBinding
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
@Test
public void testBinding() throws XQException {
SaxonXQDataSource xqds = new SaxonXQDataSource();
XQConnection xqc = xqds.getConnection();
XQPreparedExpression xqpe = xqc.prepareExpression("declare variable $v external; $v");
xqpe.bindString(new QName("v"), "Hello world!", xqc.createAtomicType(XQItemType.XQBASETYPE_STRING));
XQSequence xqs = xqpe.executeQuery();
assertTrue(xqs.next());
assertEquals("Hello world!", xqs.getAtomicValue());
xqpe.close();
xqpe = xqc.prepareExpression("declare variable $v external; $v");
xqpe.bindString(new QName("v"), "Hello", xqc.createAtomicType(XQItemType.XQBASETYPE_NCNAME));
xqs = xqpe.executeQuery();
xqs.next();
assertEquals("A-XQDC-1.7: Successful bindXXX.", XQItemType.XQITEMKIND_ATOMIC, xqs.getItemType().getItemKind());
assertEquals("A-XQDC-1.7: Successful bindXXX.", XQItemType.XQBASETYPE_NCNAME, xqs.getItemType().getBaseType());
assertEquals("A-XQDC-1.7: Successful bindXXX.", "Hello", xqs.getObject());
xqpe.close();
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:21,代码来源:SaxonParserTest.java
示例10: prepareExpression
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
@Override
public XQPreparedExpression prepareExpression(String xquery, XQStaticContext context) throws XQException {
checkState(ex_connection_closed);
if (context == null) {
throw new XQException(ex_null_context);
}
if (xquery == null) {
throw new XQException("Provided query is null");
}
BagriXQPreparedExpression exp = new BagriXQPreparedExpression(this, context);
exp.setXQuery(xquery);
prepareQuery(exp, context);
return exp;
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:17,代码来源:BagriXQConnection.java
示例11: testGetDouble
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
@Test
public void testGetDouble() throws XQException {
XQPreparedExpression xqpe = xqc.prepareExpression("declare variable $v external; $v");
try {
xqpe.bindDouble(new QName("v"), 1d, xqc.createAtomicType(XQItemType.XQBASETYPE_DOUBLE));
} catch (XQException e) {
fail("A-XQDC-1.7: bindDouble() failed with message: " + e.getMessage());
}
XQSequence xqs = xqpe.executeQuery();
xqs.next();
assertEquals("A-XQDC-1.7: Successful bindXXX.", XQItemType.XQITEMKIND_ATOMIC, xqs.getItemType().getItemKind());
assertEquals("A-XQDC-1.7: Successful bindXXX.", XQItemType.XQBASETYPE_DOUBLE, xqs.getItemType().getBaseType());
assertTrue("A-XQDC-1.7: Successful bindXXX.", 1d == xqs.getDouble());
xqpe.close();
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:17,代码来源:BagriXQItemAccessorTest.java
示例12: testBinding
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
@Test
public void testBinding() throws XQException {
XQPreparedExpression xqpe = xqc.prepareExpression("declare variable $v external; $v");
xqpe.bindString(new QName("v"), "Hello world!", xqc.createAtomicType(XQItemType.XQBASETYPE_STRING));
XQSequence xqs = xqpe.executeQuery();
assertTrue(xqs.next());
assertEquals("Hello world!", xqs.getAtomicValue());
xqpe.close();
xqpe = xqc.prepareExpression("declare variable $v external; $v");
xqpe.bindString(new QName("v"), "Hello", xqc.createAtomicType(XQItemType.XQBASETYPE_NCNAME));
xqs = xqpe.executeQuery();
xqs.next();
assertEquals("A-XQDC-1.7: Successful bindXXX.", XQItemType.XQITEMKIND_ATOMIC, xqs.getItemType().getItemKind());
assertEquals("A-XQDC-1.7: Successful bindXXX.", XQItemType.XQBASETYPE_NCNAME, xqs.getItemType().getBaseType());
assertEquals("A-XQDC-1.7: Successful bindXXX.", "Hello", xqs.getObject());
xqpe.close();
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:19,代码来源:BagriXQItemAccessorTest.java
示例13: testStoreSecurity
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
@Test
public void testStoreSecurity() throws XQException {
String dName = "../etc/samples/tpox/";
String xml;
try {
xml = readTextFile(dName + "security1500.xml");
} catch (IOException ex) {
throw new XQException(ex.getMessage());
}
String query = "declare namespace bgdb=\"http://bagridb.com/bdb\";\n" +
"declare variable $url external;\n" +
"declare variable $xml external;\n" +
"let $id := bgdb:store-document($url, $xml)\n" +
"return $id\n";
XQConnection xqc = xqds.getConnection();
XQPreparedExpression xqpe = xqc.prepareExpression(query);
xqpe.bindString(new QName("url"), "security1500.xml", xqc.createAtomicType(XQItemType.XQBASETYPE_ANYURI));
xqpe.bindString(new QName("xml"), xml, xqc.createAtomicType(XQItemType.XQBASETYPE_STRING));
XQSequence xqs = xqpe.executeQuery();
assertTrue(xqs.next());
xqs.close();
xqpe.close();
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:26,代码来源:BagriXQDataSourceTest.java
示例14: runQuery
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
private static String runQuery(String query) throws XQException {
System.out.println("runQuery: \n\t" + query);
XQDataSource xqs = new ExistXQDataSource();
String returnString = "";
xqs.setProperty("serverName", "localhost");
xqs.setProperty("port", "8080");
XQConnection conn = xqs.getConnection();
XQPreparedExpression xqpe = conn.prepareExpression(query);
XQResultSequence rs = xqpe.executeQuery();
while (rs.next()) {
returnString += rs.getItemAsString(null).replace("xmlns=\"\"", "")
+ "\n";
}
System.out.println("Query result: \n\t" + returnString);
return returnString;
}
开发者ID:XMLVersioningFramework,项目名称:XMLVersioningFramework,代码行数:24,代码来源:XChroniclerHandler.java
示例15: setUp
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
config = mock(XQueryRunConfig.class);
binderFactory = mock(TypeBinderFactory.class);
connection = mock(XQConnection.class);
expression = mock(XQPreparedExpression.class);
binder = new ContextItemBinder(binderFactory, config) {
@Override
protected String readFile(String fileName) throws IOException {
fileRead = true;
return FILE_CONTENTS;
}
};
typeBinder = mock(TypeBinder.class);
given(binderFactory.getBinder(CONTEXT_ITEM_TYPE)).willReturn(typeBinder);
}
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:17,代码来源:ContextItemBinderTest.java
示例16: executePreparedExpression
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
/**
* Helper method to execute a {@link XQPreparedExpression} and return an
* {@link OutputStream} of results. This method does not support setting write
* properties.
*
* @param xqPreparedExpression
* the expression to execute
* @return an output stream with the results
*/
public static ByteArrayOutputStream executePreparedExpression(
final XQPreparedExpression xqPreparedExpression)
{
try
{
final XQResultSequence xqResultSequence = xqPreparedExpression.executeQuery();
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
xqResultSequence.writeSequence(outputStream, null);
return outputStream;
}
catch (final XQException e)
{
throw new ApplicationException("Unable to execute prepared expression", e);
}
}
开发者ID:openfurther,项目名称:further-open-core,代码行数:25,代码来源:XQueryUtil.java
示例17: testXQueryExpression
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
/**
*
* @throws XQException
* @throws XQException
* @throws JAXBException
* @throws IOException
*/
@Test
public void testXQueryExpression() throws XQException
{
String sourceFile="synderTest.xml";
String xqFile="synderQuery1.xq";
Configuration saxonConfig = new Configuration();
SaxonXQDataSource dataSource = new SaxonXQDataSource(saxonConfig);
XQConnection conn = dataSource.getConnection();
String xsString="for $Template in doc(\"synderTest.xml\")/TemplateContainer/Template/Tags "+
" return $Template" ;
XQPreparedExpression exp = conn.prepareExpression(xsString);
URI sourcUri=new File(sourceFile).toURI();
// exp.bindString(new QName("docName"), sourcUri.getPath(), conn
// .createAtomicType(XQItemType.XQBASETYPE_STRING));
XQResultSequence result = exp.executeQuery();
String rawResult = result.getSequenceAsString(new Properties());
System.out.println("TransformTest.testXQueryExpression()..:"+rawResult);
// System.out.println(tester.transfer(sourceFile, xqFile));
}
开发者ID:NCIP,项目名称:caadapter,代码行数:31,代码来源:TransformTest.java
示例18: executeQuerySequence
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
@Override
public XQSequence executeQuerySequence(String query, Map bind_map)
throws XQException {
XQSequence sequence = null;
XQConnection connection = this.getXqConnection();
if (bind_map != null && !bind_map.isEmpty()) {
// bind
if (bind_map != null && !bind_map.isEmpty()) {
XQPreparedExpression expression = connection
.prepareExpression(query);
Set<Map.Entry> set = bind_map.entrySet();
for (Iterator<Map.Entry> it = set.iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
String value = (String) entry.getValue();
if(value!=null){
expression.bindString(new QName((String) entry.getKey()),
value, null);
}
}
sequence = expression.executeQuery();
} else {
sequence = connection.createExpression().executeQuery(query);
}
} else {
sequence = connection.createExpression().executeQuery(query);
}
return sequence;
}
开发者ID:javaliquan,项目名称:XWorld,代码行数:30,代码来源:XQSession.java
示例19: executeQuerySequence
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
public XQSequence executeQuerySequence(String query, Map bind_map)
throws XQException {
XQSequence sequence = null;
XQConnection connection = this.getXqConnection();
if (bind_map != null && !bind_map.isEmpty()) {
if(log.isDebugEnabled()){
log.debug("查询参数:"+bind_map);
}
// bind
if (bind_map != null && !bind_map.isEmpty()) {
XQPreparedExpression expression = connection
.prepareExpression(query);
Set<Map.Entry> set = bind_map.entrySet();
for (Iterator<Map.Entry> it = set.iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
String value = (String) entry.getValue();
if(value!=null){
expression.bindAtomicValue(new QName((String) entry.getKey()),
value, null);
}
}
sequence = expression.executeQuery();
} else {
sequence = connection.createExpression().executeQuery(query);
}
} else {
sequence = connection.createExpression().executeQuery(query);
}
return sequence;
}
开发者ID:javaliquan,项目名称:XWorld,代码行数:31,代码来源:XQSession.java
示例20: insertSecQuery
import javax.xml.xquery.XQPreparedExpression; //导入依赖的package包/类
public void insertSecQuery() throws XQException {
String query = "declare namespace s=\"http://tpox-benchmark.com/security\";\n" +
"declare variable $sec external;\n" +
"declare variable $uri external;\n" +
"fn:put($sec, $uri)\n";
XQPreparedExpression xqpe = xqc.prepareExpression(query);
//xqpe.bindNode(new QName("sec"), "IBM", null);
xqpe.bindString(new QName("uri"), "/library/20", null);
xqpe.executeQuery();
//System.out.println(xqs.getAtomicValue());
}
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:15,代码来源:ClientApp.java
注:本文中的javax.xml.xquery.XQPreparedExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论