Run XQuery from a Command-line Tool

Pēdējais mainījis superadmin 2018-01-12 21:34

Run XQuery from a Command-line Tool

Public source: Local source: /home/student/workspace/java-eim-demo-miscellaneous Technologies: Java (J2SDK 1.6), Ant and Maven2 build tools, JDeveloper IDE, Xerces XML library, simple edit and command-line utilities Estimated time: 15 minutes

XQuery is amore advanced language to perform querying XML data. In this class we are using MXQuery library, which is a small XQuery implementation, used e.g. in mobile devices. 


  • Run the digester Web application (i.e. execute commandline "mvn jetty:run" in the directory /home/student/workspace/java-eim-demo-digester. Check that the URL http://localhost:9080/digester/vk.xml works. This file will be used as data for XQueries. 
  • Open project "java-eim-demo-miscellaneous" in Eclipse. Execute the class lv.webkursi.klucis.eim.demo.miscellaneous.xquery.SimpleExample. Verify the output. Write some other query in the FLWOR syntax (e.g. display all those currencies, where Unit is not equal to 1). To do this, add these 3 lines of code to the end of the "main()" method:
String query4 = "let TrainingOFM07.XQueryExcercise := doc('http://localhost:9080/digester/vk.xml') " 
  + "for ... {let ... } where ... {order ... } return ...";
Context ctx4 = new Context();
executeQuery(query4, ctx2);
  • You should see the following output on the console:

Izveidojis Kalvis Apsītis 2007-10-14 15:57
This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 6.4 - Documentation