You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ben Anderson <be...@gmail.com> on 2005/03/15 20:12:46 UTC

XQueryTransformer

Hi,
For anyone using exist w/ cocoon... I'm attaching an XQueryTransformer
which can be used in place of the XQueryGenerator.  Besides leaving
the precious gerenator spot available, another advantage is that you
can use request parameters with multiple values...

The tranformer is setup in the sitemap.xmap:
  <map:transformers>
      <map:transformer name="xquery"
                       src="org.exist.cocoon.XQueryTransformer">
        <collection>@exist.uri@/db</collection>
        <user>@exist.user@</user>
        <password>@exist.pass@</password>
        <create-session>false</create-session>
        <expand-xincludes>false</expand-xincludes>

expects a document like this:
<xqtr:xquery src="xquery/1.xq">
  <xqtr:parameter name="team" value="Steelers"/>
  <xqtr:parameter name="nothingHere"/>
  <xqtr:parameter name="players">
    <xqtr:value>Greg</xqtr:value>
    <xqtr:value>Lloyd</xqtr:value>
  </xqtr:parameter>
</xqtr:xquery>

All optional parameters must appear in the list.  The transformer
returns the result of the xquery file referenced by the src attribute.
 There are certain things I left out that appear in the
XQueryGenerator, because I simply didn't need them.  So it may need
some additional work, depending on your needs.
-Ben