HOME | NEWS | FAQ | DOCUMENTATION | DOWNLOADS | SITE MAP | CONTACTS/LINKS

SQLTransformer

Warning
Note that this does not match the Cocoon method 100%. There are important differences that are discussed in the How2 example.

SQL Transformers provide an interface between Paloose and SQL-savvy database engines. They take a query and return the results of that query to the pipeline (or a suitable error message). A typical declaration of the SQLTransformer component would be:

<map:transformers default="xslt"> <map:transformer name="mysql" src="resource://lib/transforming/SQLTransformer"> <map:parameter name="type" value="mysql"/> <map:parameter name="host" value="localhost:3306"/> <map:parameter name="user" value="root"/> <map:parameter name="password" value="*******"/> </map:transformer> <map:transformer name="xslt" src="resource://lib/transforming/TRAXTransformer"> <map:use-request-parameters>true</map:use-request-parameters> </map:transformer> </map:transformers>

where

  • type — the type of this database. In this case it is a MySQL database. (At present this is the only value and will be extended in future versions.
  • host — the host where the database server is running.
  • user — the database login user.
  • password — the password associated with this user.

The pipeline would then be:

<map:pipeline> <map:match pattern="**.html"> <map:generate src="context://content/{1}.xml" label="xml-content"/> <map:transform type="mysql" label="sql-transform"> <map:parameter name="show-nr-of-rows" value="true"/> </map:transform> ... </map:match>

where

  • show-nr-of-rows — is a flag to determine whether the number of rows found is output with the result (true or false).

For an example of how to use the SQLTransformer and an explanation of the various attributes see the example How2 page.

Errors

Errors from the database engine are reported in the following typical fashion

<page:content xmlns:default="http://apache.org/cocoon/SQL/2.0" xmlns:t="http://www.hsfr.org.uk/Schema/Text"> <t:heading level="1">SQL Transform Test</t:heading> <default:sql-error xmlns="http://apache.org/cocoon/SQL/2.0"> <default:host>localhost:3306</default:host> <default:user>root</default:user> <default:password></default:password> <default:message>SQL query error: => query: select * fom composer </default:message> </default:sql-error> </page:content>
 
left footerCopyright 2006 – 2010 Hugh Field-Richards. All Rights Reserved.