Embedding XQuery in Java
Asked Answered
B

3

6

I need to retrieve some details from a MusicXML (xml) file in Java. I managed to read xml files in java - but through a web service (where I have to be online, connected to internet when I'm running my code). I came across XQuery where you can easily extract info from an XML file. But I need to embed XQuery in java (i.e. use xquery in java code), precise without using a web service. Is there any possible way, how I can embed XQuery (reading info from XML file), in java code?

Greatly appreciate any insight, suggestions and ideas. Many thanks in advance

Bev answered 28/6, 2010 at 23:42 Comment(0)
A
3

Use XQJ (XQuery for Java API). There are various tutorials for using XQJ on the web.

Anergy answered 29/6, 2010 at 0:21 Comment(5)
Thanks Chadwick. I'll go through them. So this is not making use of any web service - is it? And it's not proprietary - right? Hope I can read an xml file using xquery+java with this API then. Thanks for your time.Bev
Neither proprietary, nor web based, so it's free and can be used offline.Anergy
Thanks Chadwick - I'm working on it. Many thanks for your time. Will contact for any doubtsBev
Hi chadwick. I'm having some problems with importing the libraries of XQJ I think. I'm getting this import javax.xml.xquery.*; import net.cfoster.sedna.xqj.SednaXQDataSource; not being identified, even though I have attached the JAR files of xqj. Am I missing something? Greatly appreciate any suggestions. Advance thanksBev
Sounds like your class path needs to be set up in your environment (be it via command line, ant or maven, Eclipse or other IDE, or whatever). One simple way to check classpath at runtime is System.out.println(System.getProperty("java.class.path")); comment out the imports and statements using them till it compiles and run it to see what is actually getting set on the classpath. That or your using the wrong jars - is the net.cfoster.sedna... stuff part of XQJ?Anergy
E
5

How about SAXON XSLT & XQuery processor.SAXON

Epiphytotic answered 1/7, 2010 at 14:44 Comment(1)
Hi SadhaSivaM. thanks for the reponse. Isn't Saxon proprietary? And is it standalone (i.e. not using any web service)? Also what is XSLT? Can you pls suggest me a link to download it (I tried from the site you have linked - but I'm not sure whether I was getting the right version, there exist many). If it has a CLI where I can read the xml using xquery, then I can get it to work easily (right now I'm having some troubles getting it to work with xqj). Thanks in advance. Many thanks for your time.Bev
A
3

Use XQJ (XQuery for Java API). There are various tutorials for using XQJ on the web.

Anergy answered 29/6, 2010 at 0:21 Comment(5)
Thanks Chadwick. I'll go through them. So this is not making use of any web service - is it? And it's not proprietary - right? Hope I can read an xml file using xquery+java with this API then. Thanks for your time.Bev
Neither proprietary, nor web based, so it's free and can be used offline.Anergy
Thanks Chadwick - I'm working on it. Many thanks for your time. Will contact for any doubtsBev
Hi chadwick. I'm having some problems with importing the libraries of XQJ I think. I'm getting this import javax.xml.xquery.*; import net.cfoster.sedna.xqj.SednaXQDataSource; not being identified, even though I have attached the JAR files of xqj. Am I missing something? Greatly appreciate any suggestions. Advance thanksBev
Sounds like your class path needs to be set up in your environment (be it via command line, ant or maven, Eclipse or other IDE, or whatever). One simple way to check classpath at runtime is System.out.println(System.getProperty("java.class.path")); comment out the imports and statements using them till it compiles and run it to see what is actually getting set on the classpath. That or your using the wrong jars - is the net.cfoster.sedna... stuff part of XQJ?Anergy

© 2022 - 2024 — McMap. All rights reserved.