RE: How to connect to a database using xproc

With EMC's Calumet and our xDB XML database, you can use URIs to access
resources stored in the database. On the XProc processor side, you
provide the connection configuration (database you want to connect to,
username/password, read-only/read-write transaction etc). In the
pipeline, everything is then transparent - everywhere where you can use
URIs (p:import, p:document, p:load, p:store, p:xsl-formatter etc.), you
can use the "xhive:" URI scheme:

 

  <p:xquery>

    <p:input port="source">

      <p:document href="xhive:/path/to/doc1.xml"/>

      <p:document href="xhive:/path/to/doc2.xml"/>

      <p:document href="local/file.xml"/>

    </p:input>

      <p:inline>

        <c:query>

          declare variable $querystr as xs:string external;

          collection()//para[. contains text {$querystr} using
wildcards]

        </c:query>

      <p:inline>

    </p:input>

  </p:xquery>

 

  or:

 

  <p:store href="xhive:/path/to/doc.xml"/>

 

When you run the pipeline, the processor opens an xDB transaction and
after the pipeline has finished, it either performs a rollback or
commits (depending on what do you want).

 

The slight disadvantage of this approach is that it only works with a
single xDB database. If you want your pipeline to access multiple
databases, you would have to use a different strategy.

 

 

This approach may or may not apply to you depending on the type of the
database that you want to connect to. I generally try to avoid using
XProc steps for connecting to the database and for doing transaction
management. In XProc, this is really risky as you have to be really
careful when these steps will be actually executed. The execution order
of the steps is determined by the connections between them, but there
are situations where the processor has more freedom to decide when it
executes certain steps. Different processors may use different
strategies, and the last thing you want is to commit a transaction
before you are done with all updates. Another difficulty is that you
have to deal with potential errors during the transaction in the
pipeline.

 

Vojtech

 

 

 

From: xproc-dev-request@w3.org [mailto:xproc-dev-request@w3.org] On
Behalf Of Alex Muir
Sent: Friday, November 12, 2010 1:26 PM
To: XProc Dev
Subject: How to connect to a database using xproc

 

Hi,

I'm wondering what is involved in connecting to a database and executing
a query using xproc. I came across the following:

1.	User defined xquery connection to existDB

	1.	http://code.google.com/p/bpel-workflow/

2.	A shared a library to manage eXist databases 

	1.
http://bitbucket.org/jasulak/exist-xproc-library/wiki/Home


My client is interested to connect to the derby database.

Any general thoughts are welcome as I'm not certain where to start
exactly.

Regards

Alex

-----
The Bafiila Acoustic Trio makes easy to listen to relaxing music which
blends Western and West African influences.
http://www.facebook.com/home.php?#!/pages/Bafila-Acoustic-Trio/125611807
494851

Received on Friday, 12 November 2010 12:59:44 UTC