Hi I am new to Cocoon.  Is extending esql to allow column names and values by variable of interest to you?  Here is my diff -u:
---------------------------------

Index: esql.xsl

===================================================================

RCS file: /home/cvspublic/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl,v

retrieving revision 1.22

diff -u -r1.22 esql.xsl

--- esql.xsl 2001/10/17 14:12:14 1.22

+++ esql.xsl 2001/11/09 13:00:46

@@ -718,6 +718,16 @@

</xsp:expr>

</xsl:template>

+<xspdoc:desc>returns the value of the given column as a string</xspdoc:desc>

+<xsl:template match="esql:row-results//esql:get-string-by-variable" name="get-string-by-variable">

+ <xsp:expr>

+ <xsl:call-template name="get-string-encoded">

+ <xsl:with-param name="column-spec"><xsl:value-of select="@column"/></xsl:with-param>

+ <xsl:with-param name="resultset"><xsl:call-template name="get-resultset"/></xsl:with-param>

+ </xsl:call-template>

+ </xsp:expr>

+</xsl:template>

+

<xspdoc:desc>returns the value of the given column as a date. if a format attribute exists, its value is taken to be a date format string as defined in java.text.SimpleDateFormat, and the result is formatted accordingly.</xspdoc:desc>

<xsl:template match="esql:row-results//esql:get-date">

<xsl:choose>

@@ -897,6 +907,11 @@

<xspdoc:desc>returns the name of the given column. the column mus tbe specified by number, not name.</xspdoc:desc>

<xsl:template match="esql:row-results//esql:get-column-name">

<xsp:expr><xsl:call-template name="get-resultset"/>.getMetaData().getColumnName(<xsl:call-template name="get-column"/>)</xsp:expr>

+</xsl:template>

+

+<xspdoc:desc>returns the name of the given column. the column must be specified by a variable, not name.</xspdoc:desc>

+<xsl:template match="esql:row-results//esql:get-column-name-by-variable">

+ <xsp:expr><xsl:call-template name="get-resultset"/>.getMetaData().getColumnName(<xsl:value-of select="@column"/>)</xsp:expr>

</xsl:template>

<xspdoc:desc>returns the label of the given column. the column mus tbe specified by number, not name.</xspdoc:desc>

---------------------------------------------
This allows me to make a single chunk of xsp to display the results from a query.  Example:
 

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsp:page

language="java"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:xsp="http://apache.org/xsp"

xmlns:log="http://apache.org/xsp/log/2.0"

xmlns:esql="http://apache.org/cocoon/SQL/v2"

>

<page>

<title>Geometry</title>

<content>

<para>Set static goniometer parameters.</para>

<esql:connection>

<esql:pool>HWITCD</esql:pool>

<esql:execute-query>

<esql:query>select * from GEOMETRY, TOOL where GEOMETRY.TOOL_PK = TOOL.TOOL_PK and FLAG=Yes</esql:query>

<esql:results>

<table border="1">

<CAPTION>Goniometer Parameters</CAPTION>

<xsp:logic>

int _esql_count=0;

</xsp:logic>

<esql:row-results>

<xsp:logic>

int _esql_max=<esql:get-column-count/>;

if(_esql_count++==0)

{

</xsp:logic>

<tr>

<xsp:logic>

for(int _esql_i=1;_esql_i&lt;=_esql_max;_esql_i++)

{

<th><esql:get-column-name-by-variable column="_esql_i"/></th>

}

</xsp:logic>

</tr>

<xsp:logic>

}

</xsp:logic>

<tr>

<xsp:logic>

for(int _esql_i=1;_esql_i&lt;=_esql_max;_esql_i++)

{

<td><esql:get-string-by-variable column="_esql_i"/></td>

}

</xsp:logic>

</tr>

</esql:row-results>

</table>

</esql:results>

</esql:execute-query>

</esql:connection>

</content>

</page>

</xsp:page>

It works like a charm for all queries returning a result set.  Logic can be added to skip any particular column.

What do you think?

Roger

 

Reply via email to