IntroductionXML databases allow you to easily store, index and query XML documents. They are especially useful when dealing with document-centric applications, where the structure cannot be mapped naturally to a relational database. Orbeon Forms provides processors to integrate with Tamino XML Server databases as well as databases that support the XML:DB API, such as eXist.
NOTE: You are encouraged to use REST APIs instead of these processors whenever possible, either directly
from XForms (typically using XForms'
<xforms:submission>, which supports REST since XForms 1.1) or with the XForms Submission processor, which exposes
<xforms:submission> to XML pipelines. The eXist XML database, for example, exposes a
REST API.
eXistAPIThe eXist database can be accessed through the XML:DB API or through a REST Web API:
The REST API from XPLThe example below uses XForms Submission processor to call to the eXist REST API from XPL:
The xml:db APIXML:DB is a Java API for XML databases, just like JDBC is a Java API for relational databases. The XML:DB processor interface with the XML:DB API and so may be used with any XML databases that implements XML:DB, including eXist.
There are 4 different XML:DB processors, for querying, updating, deleting, and inserting data in
the database. All 4 processors take 2 inputs:
To connect to eXist deployed as a servlet, use:
The 4 examples below show how to use the XML:DB query, update, delete, and insert processors.
How-toCreate a named file with the xml:db processor
When using the insert processor, you cannot specify the name of the "file" that gets created in
eXist. The XML:DB API does not provide a facility to specify the name of the resource that gets
created in the database. So when using XML:DB, you need to call the
Calling the
Create a named file with the rest api
With the REST API, to create a "file"
Execute queries from the command lineIt is sometimes convenient to run queries from the command line. The method below uses the eXist REST API, the same that is used if you access eXist directly from XForms.
For more on curl, see the curl man page. Tamino XML server 4.1Software AG's Tamino provides a complete XML storage solution. Orbeon Forms allows you to easily store, query, update, and delete documents in Tamino. The following sections describe the four Orbeon Forms processors for Tamino. Configuration
All Tamino processors have a common
The configuration of the Tamino processors can be done in two ways: either system-wide via the Properties, or locally for a specific instance of the processor
through the
NOTE: The
collection configuration elements cannot be specified
system-wide.
|
| Name | Description |
|---|---|
url
|
Tamino database URL. |
username
|
Username to authenticate with the server |
password
|
Password to authenticate with the server |
collection
|
XML Collection to use |
isolation-degree
|
Type of isolation degree used (optional). One of
uncommittedDocument
|
lock-mode
|
Type of locking mode used (optional). One of
protected
|
lock-wait
|
'yes' if the query should wait for locked records to become free. (optional) |
This RelaxNG schema describes the expected document.
<element datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"><interleave><optional><element name="url"><data type="anyURI"/></element></optional><optional><element name="username"><data type="string"/></element></optional><optional><element name="password"><data type="string"/></element></optional><element name="collection"><data type="string"/></element><optional><element name="isolation-degree"><choice><value>uncommittedDocument</value><value>committedCommand</value><value>stableCursor</value><value>stableDocument</value><value>serializable</value></choice></element></optional><optional><element name="lock-mode"><choice><value>unprotected</value><value>shared</value><value>protected</value></choice></element></optional><optional><element name="lock-wait"><choice><value>yes</value><value>no</value></choice></element></optional></interleave></element>
System-wide configuration
The Tamino processors can be configured in the properties file, allowing all instances to share the same configuration. The following processor properties are allowed:
| Name | Type | Description |
|---|---|---|
url
|
anyURI
|
Tamino Server URL. |
username
|
string
|
Username to authenticate with the server. |
password
|
string
|
Password to authenticate with the server. |
These properties are set as follows:
<property as="xs:anyURI" processor-name="oxf:tamino-query" name="url" value="http://localhost/tamino/welcome_4_1_4"/>
<property as="xs:string" processor-name="oxf:tamino-query" name="username" value="..."/>
<property as="xs:string" processor-name="oxf:tamino-query" name="password" value="..."/>
The following global properties are allowed:
| Name | Type | Description |
|---|---|---|
oxf.tamino.isolation-degree |
string |
Isolation degree. Possible values are:
uncommittedDocument, committedCommand,
stableCursor, stableDocument,
serializable. See the Tamino documentation for more
details on the isolation degree.
|
oxf.tamino.lock-mode |
string |
Lock mode. Possible values are unprotected,
shared, protected. See the Tamino
documentation for more details on the lock mode.
|
oxf.tamino.lock-wait |
string |
Lock Wait Mode. If 'yes' then the query will wait for locked records to become free before returning the results. |
These properties as set as follows:
<property as="xs:string" name="oxf.tamino.isolation-degree" value="..."/>
<property as="xs:string" name="oxf.tamino.lock-mode" value="..."/>
<property as="xs:string" name="oxf.tamino.lock-wait" value="..."/>
Queries
The oxf:tamino-query processor processes queries either using
Tamino's X-Query or W3C XQuery.
data Input
The data input contains only the root element and the query.
The root element is either query for an X-Query query, or
xquery for an XQuery query.
data Output
The processor sends the result of the query in the data output.
The root element is always result.
X-Query example
<p:processor name="oxf:tamino-query"><p:input name="config"><config><url>http://localhost/tamino/welcome_4_1_4</url><username>tamino</username><password>password</password><collection>encyclopedia</collection></config></p:input><p:input name="data"><query>/jazzMusician[@ID="ParkerCharlie"]</query></p:input><p:output name="data" id="result"/></p:processor>
XQuery example
<p:processor name="oxf:tamino-query"><p:input name="config"><config><url>http://localhost/tamino/welcome_4_1_4</url><username>tamino</username><password>password</password><collection>encyclopedia</collection></config></p:input><p:input name="data"><xquery>for $m in input()/jazzMusician,$c in input()/collaboration,$a in input()/albumwhere $m/@ID= $c/jazzMusician and $c/result = $a/productNoreturn<musician>{$m/name}<album>{$a/title}</album></musician></xquery></p:input><p:output name="data" id="result"/></p:processor>
Insertions
The oxf:tamino-insert processor allows you to insert a document in
Tamino.
data Input
The
data input contains the document to insert.
Example
<p:processor name="oxf:tamino-insert"><p:input name="config"><config><url>http://localhost/tamino/welcome_4_1_4</url><username>tamino</username><password>password</password><collection>encyclopedia</collection></config></p:input><p:input name="data"><jazzMusician ID="DavisMiles" type="instrumentalist"><name><first>Miles</first><last>Davis</last></name><birthDate>1926-05-26</birthDate><instrument>trumpet</instrument></jazzMusician></p:input></p:processor>
Deletions
The oxf:tamino-delete processor allows you to remove documents
from Tamino.
data Input
The data input contains the X-Query to select the document(s)
to be removed.
Example
<p:processor name="oxf:tamino-delete"><p:input name="config"><config><url>http://localhost/tamino/welcome_4_1_4</url><username>tamino</username><password>password</password><collection>encyclopedia</collection></config></p:input><p:input name="data"><query>/jazzMusician[@ID="DavisMiles"]</query></p:input></p:processor>
Updates
The oxf:tamino-update processor allows you to update parts of
documents directly inside Tamino. An extension of XQuery is used for that
purpose. Refer to the Tamino documentation for more information.
data Input
The data input contains the XQuery expression to update one or
multiple nodes.
Example
<p:processor name="oxf:tamino-update"><p:input name="config"><config><url>http://localhost/tamino/welcome_4_1_4</url><username>tamino</username><password>password</password><collection>encyclopedia</collection></config></p:input><p:input name="data"><query>update replace input()/jazzMusician[@ID="ParkerCharlie"]/instrumentwith <instrument>piano</instrument></query></p:input></p:processor>
Transactions
Orbeon Forms initiates a transaction for every HTTP request, and commits the transaction when the pipeline is executed normally. If an exception occurs in the pipeline, the transaction in rolled back.