当前位置: 首页>>代码示例>>Java>>正文


Java XQResultSequence类代码示例

本文整理汇总了Java中javax.xml.xquery.XQResultSequence的典型用法代码示例。如果您正苦于以下问题:Java XQResultSequence类的具体用法?Java XQResultSequence怎么用?Java XQResultSequence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XQResultSequence类属于javax.xml.xquery包,在下文中一共展示了XQResultSequence类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: runPriceQuery

import javax.xml.xquery.XQResultSequence; //导入依赖的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

示例2: runSecQuery

import javax.xml.xquery.XQResultSequence; //导入依赖的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

示例3: searchSecQuery

import javax.xml.xquery.XQResultSequence; //导入依赖的package包/类
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;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:25,代码来源:ClientApp.java

示例4: readDocument

import javax.xml.xquery.XQResultSequence; //导入依赖的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: runPriceQuery

import javax.xml.xquery.XQResultSequence; //导入依赖的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

示例6: runSecQuery

import javax.xml.xquery.XQResultSequence; //导入依赖的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

示例7: searchSecQuery

import javax.xml.xquery.XQResultSequence; //导入依赖的package包/类
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;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:25,代码来源:EmbeddedApp.java

示例8: execQuery

import javax.xml.xquery.XQResultSequence; //导入依赖的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: executeQuery

import javax.xml.xquery.XQResultSequence; //导入依赖的package包/类
@Override
public XQResultSequence executeQuery(String query) throws XQException {
	
	checkState(ex_expression_closed);
	if (query == null) {
		throw new XQException("Provided query is null");
	}
	closeResults();
	
	ResultCursor<XQItemAccessor> result = connection.executeQuery(query, context);
	XQResultSequence sequence;
	if (context.getScrollability() == XQConstants.SCROLLTYPE_SCROLLABLE) {
		sequence = new ScrollableXQResultSequence(this, ((ResultCursorBase<XQItemAccessor>) result).getList());
	} else {
		sequence = new IterableXQResultSequence(this, result); 
	}
	results.add(sequence);
	return sequence;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:20,代码来源:BagriXQExpression.java

示例10: queryChildTest

import javax.xml.xquery.XQResultSequence; //导入依赖的package包/类
public void queryChildTest() throws XQException {
	String query = //"declare namespace s=\"http://tpox-benchmark.com/security\";\n" +
			//"for $sec in fn:collection(\"/{http://tpox-benchmark.com/security}Security\")/s:Security\n" +
			"for $e in fn:collection(\"/document\")/document\n" +
	  		//"where $sec/s:Symbol=$sym\n" + //'IBM'\n" +
			"return $e//child\n";
	
	XQExpression xqe = xqc.createExpression();
	//xqe.bindString(new QName("doc"), xml, xqc.createAtomicType(XQItemType.XQBASETYPE_STRING));
    XQResultSequence xqrs = xqe.executeQuery(query);

    assertNotNull(xqrs);
	assertFalse(xqrs.isClosed());

    boolean found = false;
    while (xqrs.next()) {
		System.out.println(xqrs.getItemAsString(null));
		found = true;
    }
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:21,代码来源:BagriXQAxisTest.java

示例11: queryParentTest

import javax.xml.xquery.XQResultSequence; //导入依赖的package包/类
@Test
public void queryParentTest() throws XQException {
	String query = //"declare namespace s=\"http://tpox-benchmark.com/security\";\n" +
			//"for $sec in fn:collection(\"/{http://tpox-benchmark.com/security}Security\")/s:Security\n" +
			"for $e in fn:collection(\"/document\")\n" + // /document\n" +
	  		//"where $e//child/parent::*[fn:count(*)=3]\n" + 
	  		//"where fn:count($e//child/parent::*)=3\n" + 
	  		"where $e/document/root//*[.='IBM']\n" + 
			"return $e\n";
	
	// starts with /document/root;
	// descendants of document/root; kind = text; 
	
	XQExpression xqe = xqc.createExpression();
    XQResultSequence xqrs = xqe.executeQuery(query);

    assertNotNull(xqrs);
	assertFalse(xqrs.isClosed());

    boolean found = false;
    while (xqrs.next()) {
		System.out.println(xqrs.getItemAsString(null));
		found = true;
    }
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:26,代码来源:BagriXQAxisTest.java

示例12: runQuery

import javax.xml.xquery.XQResultSequence; //导入依赖的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

示例13: executePreparedExpression

import javax.xml.xquery.XQResultSequence; //导入依赖的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

示例14: testXQueryExpression

import javax.xml.xquery.XQResultSequence; //导入依赖的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

示例15: XDM

import javax.xml.xquery.XQResultSequence; //导入依赖的package包/类
@ManagedOperation(description="Run XQuery. Returns string output specified by XQuery")
@ManagedOperationParameters({
	@ManagedOperationParameter(name = "query", description = "A query request provided in XQuery syntax"),
	@ManagedOperationParameter(name = "useXDM", description = "use XDM (true) or XQJ query interface"),
	@ManagedOperationParameter(name = "props", description = "Query processing properties")})
public String runQuery(String query, boolean useXDM, Properties props) {
	logger.debug("runQuery.enter; got query: {}, properties: {}", query, props);
	
	String result = null;
	try {
		if (useXDM) {
			ResultCursor<XQItemAccessor> cursor = queryMgr.executeQuery(query, null, props);
			result = extractResult(cursor, props);
			cursor.close();
		} else {
			XQStaticContext ctx = xqConn.getStaticContext();
			props2Context(schemaManager.getEntity().getProperties(), ctx);
			props2Context(props, ctx);
		    XQExpression xqExp = xqConn.createExpression(ctx);
		    XQResultSequence xqSec = xqExp.executeQuery(query);
		    result = xqSec.getSequenceAsString(props);
		    xqExp.close();
		}	
	} catch (Exception ex) {
		logger.error("runQuery.error", ex); 
		throw new RuntimeException(ex.getMessage());
	}
	logger.debug("runQuery.exit; returning: {}", result);
	return result;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:31,代码来源:QueryManagement.java


注:本文中的javax.xml.xquery.XQResultSequence类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。