The eXist XQJ API

Quick Start Conformance Report Compliance Definition Statement Download eXist XQJ API

eXist XQJ API

Quick Start

  1. Download and install the eXist XML Database.
  2. Start eXist via either $EXIST/bin/startup.sh or %EXIST%/bin/startup.bat
  3. Download the eXist XQJ API (exist-xqj-api-1.0.1.zip).
  4. Compile and run the following code.
import javax.xml.xquery.*;
import javax.xml.namespace.QName;
import net.xqj.exist.ExistXQDataSource;

public class QuickStart
{
  public static void main(String[] args) throws XQException
  {
    XQDataSource xqs = new ExistXQDataSource();
    xqs.setProperty("serverName", "localhost");
    xqs.setProperty("port", "8080");

    XQConnection conn = xqs.getConnection();

    XQPreparedExpression xqpe =
      conn.prepareExpression("declare variable $x as xs:string external; $x");

    xqpe.bindString(new QName("x"), "Hello World!", null);

    XQResultSequence rs = xqpe.executeQuery();

    while(rs.next())
      System.out.println(rs.getItemAsString(null));

    conn.close();
  }
}