Qizx/open

Overview

* Qizx/open is the open source edition of Qizx
* It is an XQuery processor implementing:
– XQuery 1.0
– XQuery full-Text
– XQuery Update
– XQuery 1.1 update (most features)
– XQuery Scripting

Download and Install

* Download qizxopen from its download site, e.g. qizxopen-4.1.zip
* Unzip onto a local directory, e.g. C:\prog\qizxopen-4.1
* See docs\manual.pdf for details on how to install and use qizx/open

Qizx Studio

* Start studio

C:\prog\qizxopen-4.1\bin>qizxstudio.bat

Qizx Command Line

* quizx

rem Include qizxopne in PATH
c:\set PATH=C:\prog\qizxopen-4.1\bin;%PATH%

rem Change to script directory
cd C:\prog\qizxopen-4.1\docs\samples\book_queries

rem Modify 4.xg to use absolute file path
rem declare variable $authors := collection("C:/prog/qizxopen-4.1/docs/samples/book_data/Authors/*.xml");
rem declare variable $books := collection("C:/prog/qizxopen-4.1/docs/samples./book_data/Books/*.xml");

rem Run qizx command line
quizx 4.xq

Java API

Sample Eclipse Project

* Create a new Eclipse project
* Include all qizxopen jar files located in “C:\prog\qizxopen-4.1\lib” directory in the Elipse build directory
* Create a new sample xml file named books.xml in etc directory:

<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
  <title lang="en">Everyday Italian</title>
  <author>Giada De Laurentiis</author>
  <year>2005</year>
  <price>30.00</price>
</book>
<book category="CHILDREN">
  <title lang="en">Harry Potter</title>
  <author>J K. Rowling</author>
  <year>2005</year>
  <price>29.99</price>
</book>
<book category="WEB">
  <title lang="en">XQuery Kick Start</title>
  <author>James McGovern</author>
  <author>Per Bothner</author>
  <author>Kurt Cagle</author>
  <author>James Linn</author>
  <author>Vaidyanathan Nagarajan</author>
  <year>2003</year>
  <price>49.99</price>
</book>
<book category="WEB">
  <title lang="en">Learning XML</title>
  <author>Erik T. Ray</author>
  <year>2003</year>
  <price>39.95</price>
</book>
</bookstore>

* Create a sample XQuery file named books.xq in the etc directory:

for $x in doc("etc/books.xml")/bookstore/book
where $x/price>30
order by $x/title
return $x/title

* Use Qizx Java API in Java program:

import com.qizx.api.*;
import com.qizx.util.basic.*;
...
 
public void testBooks1Xq() 
throws CompilationException, 
       EvaluationException, 
       IOException {
  this.doXQuery("books.xq");
}
 
private void doXQuery(String scriptFile)
  throws CompilationException, 
    EvaluationException, 
    IOException {
  String userDirStr = System.getProperty("user.dir");
  String etcDirStr = userDirStr + "/etc/";
  File etcDir = new File(etcDirStr);
  System.out.println(etcDir);
  XQuerySessionManager sm = new XQuerySessionManager(etcDir.toURL());
 
  XQuerySession sess = sm.createSession();
 
  Expression expr = sess.compileExpression(
      FileUtil.loadString(etcDirStr + scriptFile));
  ItemSequence results = expr.evaluate();
  while (results.moveToNextItem()){
    Item result = results.getCurrentItem();
    System.out.println(result.getString());
  }
}

* Sample output:

Learning XML
XQuery Kick Start

References

* QizxOpen

This entry was posted in xquery. Bookmark the permalink.

2 Responses to Qizx/open

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.