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

starblue
  • 55,348
  • 14
  • 97
  • 151
Dolphin
  • 375
  • 2
  • 8
  • 16

3 Answers3

5

How about SAXON XSLT & XQuery processor.SAXON

kadalamittai
  • 2,076
  • 1
  • 16
  • 19
  • 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 Jul 01 '10 at 16:51
3

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

Chadwick
  • 12,555
  • 7
  • 49
  • 66
  • 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 Jun 29 '10 at 05:45
  • Neither proprietary, nor web based, so it's free and can be used offline. – Chadwick Jun 29 '10 at 17:23
  • Thanks Chadwick - I'm working on it. Many thanks for your time. Will contact for any doubts – Dolphin Jun 30 '10 at 13:24
  • 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 Jul 01 '10 at 16:52
  • 1
    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 Jul 01 '10 at 19:00