views:

157

answers:

2

Hi

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

+1  A: 

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

Chadwick
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.
Dolphin
Neither proprietary, nor web based, so it's free and can be used offline.
Chadwick
Thanks Chadwick - I'm working on it. Many thanks for your time. Will contact for any doubts
Dolphin
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 thanks
Dolphin
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?
Chadwick
+2  A: 

How about SAXON XSLT & XQuery processor.SAXON

kadalamittai
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.
Dolphin