You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Rolf Heckemann <ra...@doc.ic.ac.uk> on 2003/08/09 18:00:40 UTC
[newbie] Questions about esql, xsl
To acquaint myself with the sitemap and the ESQL logicsheet, I wrote a
small application that takes a database named IXIDB, lists the tables
and shows the table contents. The goal was not to have to adapt the
application if database tables were to change. One of the problems I
found difficult to deal with was extracting the table descriptions so
I could turn the fields into headers (<th>) in the output. I solved
this with a dynamically generated XSL sheet. Now I'm wondering:
Is this 'The Way' or are there more elegant/ more flexible/ easier/
approaches to solve this problem? Would nested queries help? I
tried, but found them difficult to debug.
Is this likely to work with future versions of Cocoon (I did it in
2.0.4)? Or is ESQL going to be superceded by the SQL Transformer?
I would appreciate any hints, comments, 'RTFM' pointers or anything
else that will help me on my learning curve...
Thanks
Rolf Heckemann
============= sitemap.xmap =============
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:generators default="file"/>
<map:transformers default="xslt"/>
<map:readers default="resource"/>
<map:serializers default="html"/>
<map:matchers default="wildcard"/>
</map:components>
<map:pipelines>
<map:pipeline>
<map:match pattern="dbreq">
<map:generate src="xsp/dbreq.xsp" type="serverpages"/>
<map:transform src="stylesheets/query2html.xsl"/>
<map:serialize type="html"/>
</map:match>
</map:pipeline>
<map:pipeline>
<map:match pattern="showtable">
<map:generate src="xsp/showtable.xsp" type="serverpages"/>
<map:transform src="cocoon:/descrtable"/>
<map:serialize type="html"/>
</map:match>
</map:pipeline>
<map:pipeline>
<map:match pattern="descrtable">
<map:generate src="xsp/descrtable.xsp" type="serverpages"/>
<map:transform src="stylesheets/query2html.xsl"/>
<map:serialize type="html"/>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>
============= dbreq.xsp =============
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page
language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:xsp-response="http://apache.org/xsp/response/2.0"
xmlns:log="http://apache.org/xsp/log/2.0"
xmlns:esql="http://apache.org/cocoon/SQL/v2">
<page>
<esql:connection>
<esql:pool>workbench</esql:pool>
<esql:execute-query>
<esql:query>
show tables
</esql:query>
<esql:results>
Tables in IXIDB:
<br/>
<esql:row-results>
<a>
<xsp:attribute
name="href">showtable?table=<esql:get-string
column="Tables_in_IXIDB"/></xsp:attribute>
<esql:get-string column="Tables_in_IXIDB"/>
</a>
<br/>
</esql:row-results>
</esql:results>
<esql:no-results>No results</esql:no-results>
<esql:error-results>Error in query</esql:error-results>
</esql:execute-query>
</esql:connection>
</page>
</xsp:page>
============= query2html.xsl =============
(This is essentially the same as the example
xxx2html.xsl's from the Cocoon dist.)
============= showtable.xsp =============
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page
language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:xsp-response="http://apache.org/xsp/response/2.0"
xmlns:log="http://apache.org/xsp/log/2.0"
xmlns:esql="http://apache.org/cocoon/SQL/v2">
<page>
<esql:connection>
<esql:pool>workbench</esql:pool>
<esql:execute-query>
<esql:query>
select * from <xsp-request:get-parameter name="table"/>;
</esql:query>
<esql:results>
<esql:row-results>
<row>
<esql:get-columns />
</row>
</esql:row-results>
</esql:results>
<esql:no-results>No results</esql:no-results>
<esql:error-results>Error in query</esql:error-results>
</esql:execute-query>
</esql:connection>
</page>
</xsp:page>
============= descrtable.xsp =============
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page
language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:xsp-response="http://apache.org/xsp/response/2.0"
xmlns:log="http://apache.org/xsp/log/2.0"
xmlns:esql="http://apache.org/cocoon/SQL/v2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<esql:connection>
<esql:pool>workbench</esql:pool>
<esql:execute-query>
<esql:query>
describe <xsp-request:get-parameter name="table"/>
</esql:query>
<esql:results>
<xsl:template match="page">
<html>
<head>
<title>Showing table</title>
</head>
<body>
<table border="1">
<tr>
<esql:row-results>
<th>
<esql:get-string column="Field" />
</th>
</esql:row-results>
</tr>
<xsl:apply-templates/>
</table>
</body>
</html>
</xsl:template>
</esql:results>
<esql:no-results>No describe results</esql:no-results>
<esql:error-results>Error describe query</esql:error-results>
</esql:execute-query>
<xsl:template match="row">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<esql:execute-query>
<esql:query>
describe <xsp-request:get-parameter name="table"/>
</esql:query>
<esql:results>
<esql:row-results>
<xsl:template>
<xsp:attribute name="match"><esql:get-string column="Field" /></xsp:attribute>
<td>
<xsl:value-of select="."/>
</td>
</xsl:template>
</esql:row-results>
</esql:results>
<esql:no-results>No describe results</esql:no-results>
<esql:error-results>Error describe query</esql:error-results>
</esql:execute-query>
</esql:connection>
</xsl:stylesheet>
</xsp:page>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [newbie] Questions about esql, xsl
Posted by Rolf Heckemann <ra...@doc.ic.ac.uk>.
On Sat, Aug 09, 2003 at 10:06:22PM +0200, Christian Haul wrote:
[...]
> A dynamic XSLT seems unneeded. A static XSLT like the stupid.xsl from
> the samples should do (it's not brilliant, thus "stupid"....) Another
> option is to use the ResultSetMetaData (see esql.xsl) and use JAVA in
> your XSP to create the table heading.
>
> > Is this likely to work with future versions of Cocoon (I did it in
> > 2.0.4)? Or is ESQL going to be superceded by the SQL Transformer?
>
> Historically, ESQL was supposed to replace the transformer IIRC but I
> believe both have their merrits and will stay in Cocoon.
Your pointers are very helpful. Thank you very much.
Rolf Heckemann
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [newbie] Questions about esql, xsl
Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 09.Aug.2003 -- 05:00 PM, Rolf Heckemann wrote:
> To acquaint myself with the sitemap and the ESQL logicsheet, I wrote a
> small application that takes a database named IXIDB, lists the tables
> and shows the table contents. The goal was not to have to adapt the
> application if database tables were to change. One of the problems I
> found difficult to deal with was extracting the table descriptions so
> I could turn the fields into headers (<th>) in the output. I solved
> this with a dynamically generated XSL sheet. Now I'm wondering:
>
> Is this 'The Way' or are there more elegant/ more flexible/ easier/
> approaches to solve this problem? Would nested queries help? I
> tried, but found them difficult to debug.
A dynamic XSLT seems unneeded. A static XSLT like the stupid.xsl from
the samples should do (it's not brilliant, thus "stupid"....) Another
option is to use the ResultSetMetaData (see esql.xsl) and use JAVA in
your XSP to create the table heading.
> Is this likely to work with future versions of Cocoon (I did it in
> 2.0.4)? Or is ESQL going to be superceded by the SQL Transformer?
Historically, ESQL was supposed to replace the transformer IIRC but I
believe both have their merrits and will stay in Cocoon.
Chris.
--
C h r i s t i a n H a u l
haul@informatik.tu-darmstadt.de
fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org