Exporting data from a database and publishing in a web server
We propose here another scenario extracting data from a database and
publishing it inside a website.
We suppose we have one database "persons" containg one table "person"
with the following content :
mysql> select * from person;
+-----------+----------+--------------------+
| firstname | lastname |
address
|
+-----------+----------+--------------------+
| victor | georges | 10, indiana street |
| joanna | georges | 11, indiana street |
| paul | georges | 12, indiana
street |
| herbert | georges | 13, indiana street |
| isidor | georges | 14, indiana street |
+-----------+----------+--------------------+
5 rows in set (0.00 sec)
We begin to create a new task for exporting the database "persons". We
select the first line of the tasks table and we select the "DBEXPORT"
Action. We also update the name field.

We begin by connecting to our
database located at jdbc:mysql://127.0.0.1/persons.
This name is
depending on the current database type, the user has only to complete a
part of the database url. We include too a user id and a password. Then
we
connect to the database. We have now the browser displaying our
"persons" database content.

In the second step we select the "Export" panel and we generate a new
SQL query for our table "person" by clicking on
.
It generates an SQL query for each field of our table and a template
for creating an output document. We test our query by clicking on
. It generates the following dialog
:

This dialog contains a subset of our final XML document.
The final result path is set by using the last panel "Target". We
decide to store it inside this path
/home/test/xflows/dbexport/test1.xml.
Now we create second task for transforming our previous document to
HTML using XSLT.
We create a simple stylesheet "export.xsl" for this result document
using our
favorite XML editor (like editix
: http://www.editix.com).
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns="http://www.w3.org/TR/xhtml1/strict"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/xflows_export">
<html>
<body>
<xsl:apply-templates select="record"/>
</body>
</html>
</xsl:template>
<xsl:template match="record">
<p>
<xsl:value-of select="firstname"/>
,
<xsl:value-of select="lastname"/>
,
<xsl:value-of select="address"/>
</p>
</xsl:template>
</xsl:stylesheet>
We insert another task for transforming our database result to
HTML :

We need'nt the "XML source filter" or a "Target name" fields because we
are working on a whole document and not on a directory.
We run the
scenario with this action
from the scenario menu or from the main toolbar.
We can save our scenario or reuse it in a batch mode (look at the
manual for batch usage).