java使用xquery,我想在Java中使用XQuery For Xml处理

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:

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.

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

解决方案

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,

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.

And here is the link,

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 = "{1 + 1}";

XQPreparedExpression expr = con.prepareExpression(query);

XQSequence result = expr.executeQuery();

System.out.println(result.getSequenceAsString(null));

result.close();

expr.close();

con.close();

}

}

With following JARS in path,

apache-xmlbeans

orai18n-mapping

oxquery

xmlparserv2_sans_jaxp_services

xqjapi

Also another suggestion,

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.

Also this link here Embedding XQuery in Java suggests usage of SAXON XSLT & XQuery processor. SAXON

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值