Zorba (XQuery processor)

{{More citations needed|date=February 2024}}

{{Short description|Open-source query processor}}

{{Portal|Free and open-source software}}

Zorba is an open source query processor written in C++,{{Cite book |last1=Changqing |first1=Li |url=https://books.google.com/books?id=6iMI8y1pydEC&dq=%22Zorba%22+XQuery+processor+-wikipedia&pg=PA40 |title=Advanced Applications and Structures in XML Processing: Label Streams, Semantics Utilization and Data Query Technologies: Label Streams, Semantics Utilization and Data Query Technologies |last2=Wang |first2=Ling, Tok |date=2010-02-28 |publisher=IGI Global |isbn=978-1-61520-728-2 |pages=40 |language=en}} implementing

Zorba is distributed under Apache License, Version 2.0.

The project is mainly supported by the [https://web.archive.org/web/20120624062120/http://www.zorba-xquery.com/flwor/index FLWOR Foundation], Oracle, and {{usurped|1=[https://web.archive.org/web/20090209154228/http://www.28msec.com/ 28msec]}}.

Specifications

Zorba provides the implementation of the following W3C specifications:

  • [http://www.w3.org/TR/xquery/ XQuery 1.0]
  • [http://www.w3.org/TR/xquery-30/ XQuery 3.0]
  • [http://www.w3.org/TR/xquery-update-10/ XQuery Update Facility 1.0]
  • [http://www.w3.org/TR/xpath-full-text-10/ XQuery and XPath Full Text 1.0]
  • [http://www.w3.org/TR/xqueryx/ XML Syntax for XQuery 1.0]
  • [http://www.w3.org/XML/Schema XML Schema]
  • [http://www.w3.org/TR/xslt XSL Transformations (XSLT)]
  • [http://www.w3.org/TR/xsl/ XSL Formatting Objects]

Zorba also provides implementations of:

= Scripting =

[http://www.zorba.io/documentation/latest/zorba/scripting_tutorial Scripting Extension] is an open specification that provides semantic for side-effects in XQuery or JSONiq programs.

It also provides a user-friendly syntax for imperative programming within such programs.

The following code snippet is an example of the Scripting syntax. It computes a sequence containing all the Fibonacci numbers that are less than 100.

(: this is a variable declaration statement :)

variable $a as xs:integer := 0;

variable $b as xs:integer := 1;

variable $c as xs:integer := $a + $b;

variable $fibseq as xs:integer* := ($a, $b);

while ($c lt 100) {

(: this is a variable assignment statement :)

$fibseq := ($fibseq, $c);

$a := $b;

$b := $c;

$c := $a + $b;

}

$fibseq

The following is an example of CRUD operations using Scripting, XQuery, and XQuery Update.

variable $stores := doc("stores.xml")/stores;

(: Create :)

insert node 4NY into $stores;

(: Update :)

replace value of node $stores/store[state="NY"]/store-number with "5";

(: Delete :)

delete node $stores/store[state != "NY"];

(: Read :)

$stores

= Data Definition Facility =

[http://www.zorba.io/documentation/latest/zorba/specifications/xqddf Data Definition Facility] provides a semantic for persistent artifacts such as collections and indexes in XQuery or JSONiq programs.

For instance, the following code snippets declares a collection named entries and an index on that collection named entry.

module namespace g = "http://www.zorba-xquery.com/guestbook";

import module namespace db = "http://www.zorba-xquery.com/modules/store/static/collections/dml";

declare namespace an = "http://www.zorba-xquery.com/annotations";

(: Declares a collection named entries :)

declare collection g:entries as element(entry);

(: Declares a variable that points to the g:entries collection :)

declare variable $g:entries := xs:QName('g:entries');

(: Declares an index named entry on top of the entries collection :)

declare %an:automatic %value-equality index g:entry

on nodes db:collection(xs:QName('g:entries'))

by xs:string(@id) as xs:string;

Storage

Zorba provides a pluggable store so it can be used on different kind of environments: disk, database, browser.

By default, Zorba is built with a main memory store.

{{usurped|1=[https://web.archive.org/web/20090209154228/http://www.28msec.com/ 28msec]}} implements a store on top of MongoDB.

The [http://xqib.org/ XQuery in the Browser] project has built a browser plugin for Zorba and leverages the DOM as its store.

APIs

Zorba is usable through [http://www.zorba.io/documentation/latest/languages different host languages]: C++, C, XQJ / Java, PHP, Python, C#, Ruby, and even [http://www.zorba.io/documentation/latest/modules/zorba/languages/xqxq XQuery/JSONiq].

Zorba is also available as a [http://www.zorba.io/documentation/latest/zorba/cli command-line tool].

[http://xqdt.org/ XQDT] is an XQuery plugin for the Eclipse (IDE). It fully supports Zorba API and syntax.

Modules

Zorba provides more than 70 XQuery modules for building applications. Some of these modules are:

  • File system, Email, HTTP client, OAuth client
  • XQuery and JSONiq Data Model Processing: typing, atomic items, and nodes.
  • Full-text: tokenizer, stemmer, thesaurus lookup.
  • Data Cleaning: phonetic similarities, set similarities, conversions.
  • Data Conversion: Base64, CSV, HTML, JSON, XML
  • Data Formatting: XSL-FO
  • Introspection and Reflection
  • Cryptography
  • Image processing

References

{{reflist}}