我想在Java中使用XQuery For Xml处理 [英] I want to use XQuery For Xml processing in java

查看:133
本文介绍了我想在Java中使用XQuery For Xml处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用XQuery从Java中的Xml提取数据,但是我没有得到为此添加的Jar.我在Google上进行了很多搜索,但没有任何有用的示例.例如,我得到以下链接:

I want to use XQuery for fetching data from Xml in java, but I am not getting which Jar I need to add for this. I searched in google lot but haven't got any useful example. For example I got following link:

https://docs.oracle.com/database/121/ADXDK/adx_j_xqj.htm

然后我在这里没有得到jar文件.任何人都知道如何通过一个简单的示例开始在Java中使用XQuery将会非常有帮助.经过大量搜索之后,我得到了这个链接,它说Xqjapi.jar随oracle数据库一起提供.

Then I am not getting jar file mentioned here. Anyone know how to start using XQuery in Java with a simple example will be very helpful. After lot of search I have got this link which is saying Xqjapi.jar comes with oracle database.

我可以在Java中使用任何开放式api来使用XQuery吗?

Is there any open source api I can use in Java for using XQuery?

推荐答案

嗯,还有另一种方法来获取所需的JARS,您无需为此安装oracle数据库.我在此链接中找到了解决方案,

Well, there is another approach to get the required JARS, you need not install oracle database for that. I found the solution in this link,

http://orafmwsoa.blogspot. co.at/2014/06/running-xquery-from-java-applications.html

但是您不必遍历整个链接,需要注意的重要一点是,所有必需的JARS都可以从Oracle XQuery for Hadoop实现中获得.

But you need not go through the entire link, what important point to note is, all necessary JARS are available from Oracle XQuery for Hadoop implementation.

这是链接,

Oracle XQuery for Hadoop 2.4.1

只需下载Oracle XQuery for Hadoop 4.1.0并解压并创建一个带有路径库的普通Java项目.

Just download Oracle XQuery for Hadoop 4.1.0 and extract and create a normal Java Project with the libraries in path.

我从您的链接尝试了此示例,并且有效

I tried this example from your link, and it works

import javax.xml.xquery.XQConnection;
import javax.xml.xquery.XQException;
import javax.xml.xquery.XQPreparedExpression;
import javax.xml.xquery.XQSequence;
import oracle.xml.xquery.OXQDataSource;


public class HelloWorld {

public static void main(String[] args) throws XQException {
    OXQDataSource ds = new OXQDataSource();
    XQConnection con = ds.getConnection();
    String query = "<hello-world>{1 + 1}</hello-world>";
    XQPreparedExpression expr = con.prepareExpression(query); 
    XQSequence result = expr.executeQuery();
    System.out.println(result.getSequenceAsString(null));
    
    result.close();
    expr.close();
    con.close();
}

}

在路径中跟随JARS

apache-xmlbeans

apache-xmlbeans

orai18n映射

oxquery

xmlparserv2_sans_jaxp_services

xmlparserv2_sans_jaxp_services

xqjapi

还有另一个建议,

  1. 我安装了Oracle Express Edition 11.2 OracleXE112_Win64,但是它没有必需的JARS,XE的功能可能有限,因此请尝试安装其他版本.
  2. 此链接也在Java中嵌入XQuery 建议使用SAXON XSLT& XQuery处理器. SAXON
  1. I installed Oracle Express Edition 11.2 OracleXE112_Win64 and it didn't had the required JARS, XE may be has limited functionality, so try installing different one.
  2. Also this link here Embedding XQuery in Java suggests usage of SAXON XSLT & XQuery processor. SAXON

这篇关于我想在Java中使用XQuery For Xml处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆