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


Java XQConnection.prepareExpression方法代码示例

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


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

示例1: testBinding

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

示例2: testStoreSecurity

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

示例3: runQuery

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

示例4: testXQueryExpression

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

示例5: executeQuerySequence

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

示例6: executeQuerySequence

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

示例7: setUpBeforeClass

import javax.xml.xquery.XQConnection; //导入方法依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {

	String dName = "../../etc/samples/test/";
	String xml;
	try {
		xml = readTextFile(dName + "axis.xml");
	} catch (IOException ex) {
		throw new XQException(ex.getMessage());
	}

	xqds = new BagriXQDataSource();
    xqds.setProperty(BagriXQDataSource.ADDRESS, "localhost:10500");
    xqds.setProperty(BagriXQDataSource.SCHEMA, "default");
    xqds.setProperty(BagriXQDataSource.USER, "guest");
    xqds.setProperty(BagriXQDataSource.PASSWORD, "password");
    xqds.setProperty(BagriXQDataSource.XQ_PROCESSOR, "com.bagri.xquery.saxon.XQProcessorClient");
    xqds.setProperty(BagriXQDataSource.XDM_REPOSITORY, "com.bagri.client.hazelcast.impl.SchemaRepositoryImpl");

	String query = "declare namespace bgdb=\"http://bagridb.com/bdb\";\n" +
			"declare variable $sec external;\n\n" + 
			"for $id in bgdb:store-document($sec)\n" +
			"return $id\n";

	XQConnection xqc = xqds.getConnection();
	try {
		XQPreparedExpression xqpe = xqc.prepareExpression(query);
	    xqpe.bindString(new QName("sec"), xml, xqc.createAtomicType(XQItemType.XQBASETYPE_STRING));
	    XQSequence xqs = xqpe.executeQuery();
	    if (xqs.next()) {
	    	axisId = xqs.getLong();
		    xqpe.close();
	    } else {
	    	xqpe.close();
	    	throw new XQException("no response from store-document function");
	    }
	} finally {
		xqc.close();
	}
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:41,代码来源:BagriXQAxisTest.java

示例8: getExpression

import javax.xml.xquery.XQConnection; //导入方法依赖的package包/类
public XQPreparedExpression getExpression(XQConnection connection) throws Exception {
    XQPreparedExpression preparedExpression = connection
            .prepareExpression(contentFactory.getXQueryContentAsStream());
    contextItemBinder.bindContextItem(connection, preparedExpression);
    variablesBinder.bindVariables(connection, preparedExpression);
    return preparedExpression;
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:8,代码来源:ExpressionFactory.java

示例9: testXQueryTransform

import javax.xml.xquery.XQConnection; //导入方法依赖的package包/类
/**
	 * Test method for {@link gov.nih.nci.cbiit.cmts.transform.XQueryBuilder#getXQuery()}.
	 * @throws XQException
	 */
	@Test
	public void testXQueryTransform() throws XQException {
//		String sourceFile="workingspace/simpleMapping/shiporder.xml";
//		String xqFile="workingspace/simpleMapping/testXQ1.xq";

		String sourceFile="synderTest.xml";
		String xqFile="synderQuery.xq";
		InputStream in;
		try {
			in = new FileInputStream(new File(xqFile));
			InputStreamReader inputStream=new InputStreamReader(in);
			Configuration saxonConfig = new Configuration();
			SaxonXQDataSource dataSource = new SaxonXQDataSource(saxonConfig);
			XQConnection conn = dataSource.getConnection();
			XQPreparedExpression exp = conn.prepareExpression(inputStream);
			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()..:\n"+rawResult);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
//		XQueryTransformer tester= new XQueryTransformer();
//		System.out.println(tester.transfer(sourceFile, xqFile));
	}
 
开发者ID:NCIP,项目名称:caadapter,代码行数:33,代码来源:TransformTest.java

示例10: testXQConnection

import javax.xml.xquery.XQConnection; //导入方法依赖的package包/类
@Test
public void testXQConnection() throws Exception {
	final Server srv = Server.getInstance();
	final URL fname = BaseXTestSuite.class.getClassLoader().getResource( "sampleHarvest.xml" );
	File file = new File(fname.toURI());
	srv.startup(file);
	final XQDataSource xqs = new BaseXXQDataSource();
	xqs.setProperty("serverName", Server.SERVER_NAME);
	xqs.setProperty("port", String.valueOf(Server.PORT));
	xqs.setProperty("databaseName", Server.DATABASE_NAME);
	xqs.setProperty("user", Client.USER);
	xqs.setProperty("password", Client.PASSWORD);

	final XQConnection conn = xqs.getConnection();
	try {
		final String query = "declare default element namespace \"http://www.w3.org/1998/Math/MathML\";\n" +
				"for $m in //*:expr return \n" +
				"for $x in $m//*:apply\n" +
				"[*[1]/name() = 'divide']\n" +
				"where\n" +
				"fn:count($x/*) = 3\n" +
				"return\n" +
				"<result>{$m/@url}</result>";

		final XQPreparedExpression xqpe = conn.prepareExpression( query );
		final XQResultSequence rs = xqpe.executeQuery();

		final String res = rs.getSequenceAsString( null );

		Assert.assertEquals( "<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"4#math.4.5\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"4#math.4.5\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"5#math.5.2\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"5#math.5.17\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"5#math.5.18\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"5#math.5.18\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"5#math.5.19\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"5#math.5.19\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"5#math.5.19\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"5#math.5.20\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"5#math.5.21\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"5#math.5.22\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"5#math.5.23\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"6#math.6.11\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"6#math.6.14\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"6#math.6.15\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"6#math.6.15\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"6#math.6.15\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"6#math.6.15\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"6#math.6.20\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"7#math.7.0\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"7#math.7.1\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"7#math.7.1\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"7#math.7.2\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"7#math.7.2\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"7#math.7.3\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"7#math.7.3\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"7#math.7.4\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"8#math.8.6\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"8#math.8.7\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"8#math.8.21\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"8#math.8.22\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"8#math.8.23\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"8#math.8.33\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"8#math.8.34\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"8#math.8.35\"/> " +
				"<result xmlns=\"http://www.w3.org/1998/Math/MathML\" url=\"dummy29\"/>"
				, res );
	} finally {
		conn.close();
	}
}
 
开发者ID:ag-gipp,项目名称:mathosphere,代码行数:72,代码来源:ServerTest.java


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