I want to use XQuery processing for Xml in java

I want to use XQueryto extract data from Xml in java, but I do not get which Jar I need to add for this. I searched in google lot but did not get any useful example. For example, I got the following link:

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

Then I do not get the jar file mentioned here. Does anyone know how to start using XQuery in Java with a simple example would be very helpful. After much searching, I have this link that says it Xqjapi.jarcomes with an oracle database. A.

https://technology.amis.nl/2011/07/30/running-xquery-from-java-applications-using-the-xqj-api-and-the-oracle-xdk-implementation/

Is there any open api script I can use in Java to use XQuery?

+4
source share
2 answers

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

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

But you do not need to go through the entire link, which is important to note, all the necessary JARSare available from Oracle XQuery for implementing Hadoop.

And here is the link,

Oracle XQuery for Hadoop 2.4.1

Just download Oracle XQuery for Hadoop 4.1.0and extract and create a normal Java project with libraries on the go.

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();
}

}

With the next one JARSon the way,

Apache-XMLBeans

orai18n-mapping

oxquery

xmlparserv2_sans_jaxp_services

xqjapi

,

  • Oracle Express Edition 11.2 OracleXE112_Win64, JARS, XE , .
  • XQuery Java SAXON XSLT XQuery. SAXON
+5

XML filestore, XQuery , Saxon.

0

All Articles