Here is a small patch to esql.xsl r1.13.2.8

1) fix runtime compilation error described in a previous posting to this thread
copy the type from <esql:parameter direction="out" 
type="oracle.jdbc.driver.OracleTypes.CURSOR"/>
directly into the generated code rather than use reflection as in EsqlQuery.getType()
(which should be removed if this patch is applied). Argument for doing this was 
presented in my
previous posting.

2) add paging for result set obtained from a column
e.g.
        <esql:call-results>
          <esql:use-results>
            <esql:result><esql:get-object column="8" from-call="true"/></esql:result>

            <esql:skip-rows><xsp:expr>sessionData.getRow() - 
1</xsp:expr></esql:skip-rows>
            
<esql:max-rows><xsp:expr>sessionData.getRowsPerPage()</xsp:expr></esql:max-rows>


Index: src/java/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl
===================================================================
RCS file: 
/home/cvspublic/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl,v
retrieving revision 1.13.2.8
diff -u -b -r1.13.2.8 esql.xsl
--- src/java/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl     11 Aug 
2002 20:08:57 -0000      1.13.2.8
+++ src/java/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl     19 Aug 
+2002 01:06:50 -0000
@@ -1,6 +1,7 @@
 <?xml version="1.0"?><!-- -*- xsl -*- -->

-<!-- $Id: esql.xsl,v 1.13.2.8 2002/08/11 20:08:57 haul Exp $-->
+<!-- $Id: esql.xsl,v 1.15 2002/08/19 00:24:23 neil Exp $-->
+<!-- Modified from Apache's Id: esql.xsl,v 1.13.2.8 2002/08/11 20:08:57 haul Exp -->
 <!--

  ============================================================================
@@ -56,7 +57,7 @@
  * ESQL Logicsheet
  *
  * @author ?
- * @version CVS $Revision: 1.13.2.8 $ $Date: 2002/08/11 20:08:57 $
+ * @version CVS $Revision: 1.15 $ $Date: 2002/08/19 00:24:23 $
 -->

 <xsl:stylesheet version="1.0"
@@ -978,12 +979,27 @@

 <xspdoc:desc>creates a nested query like block that uses the result set obtained from 
a column as current result set.</xspdoc:desc>
 <xsl:template name="use-results" match="esql:use-results[child::esql:result]">
+  <xsl:variable name="maxrows"><xsl:call-template 
+name="get-nested-string"><xsl:with-param name="content"
select="esql:max-rows"/></xsl:call-template></xsl:variable>
+  <xsl:variable name="skiprows"><xsl:call-template 
+name="get-nested-string"><xsl:with-param name="content"
select="esql:skip-rows"/></xsl:call-template></xsl:variable>
 <xsp:logic>
   // nested result set
     if (_esql_query != null) {
       _esql_queries.push(_esql_query);
     }
     _esql_query = new EsqlQuery((ResultSet) <xsl:apply-templates 
select="esql:result/*"/>);
+
+    <xsl:if test="esql:max-rows">
+      try {
+        _esql_query.setMaxRows( Integer.parseInt(String.valueOf(<xsl:copy-of 
+select="$maxrows"/>).trim()) );
+      } catch (NumberFormatException e) {}
+    </xsl:if>
+
+    <xsl:if test="esql:skip-rows">
+      try {
+        _esql_query.setSkipRows( Integer.parseInt(String.valueOf(<xsl:copy-of 
+select="$skiprows"/>).trim()) );
+      } catch (NumberFormatException e) {}
+    </xsl:if>
+
     {
        <xsl:call-template name="do-results"/>
     }
@@ -1098,7 +1114,8 @@
     <xsl:when test="$type='AsciiStream'">Types.LONGVARCHAR</xsl:when>
     <xsl:when test="$type='UnicodeStream'">Types.LONGVARCHAR</xsl:when>
     <xsl:when test="$type='BinaryStream'">Types.VARBINARY</xsl:when>
-    <xsl:when test="contains($type,'.')">EsqlQuery.getType("<xsl:value-of 
select="$type"/>")</xsl:when>
+    <!-- handle DBMS specific types e.g. oracle.jdbc.driver.OracleTypes.CURSOR -->
+    <xsl:when test="contains($type,'.')"><xsl:value-of select="$type"/></xsl:when>
     <xsl:otherwise>Types.<xsl:value-of
select="translate(@type,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/></xsl:otherwise>
   </xsl:choose>
 </xsl:template>



-----Original Message-----
From: neil [mailto:[EMAIL PROTECTED]]
Sent: Monday, 19 August 2002 9:57 AM
To: '[EMAIL PROTECTED]'; Cocoon-Users (E-mail)
Subject: RE: esql patch for paging and ResultSets from Oracle stored
procs


I would rather esql copied the type from <esql:parameter direction="out" 
type="oracle.jdbc.driver.OracleTypes.CURSOR"/>
directly into the generated code than use reflection as in EsqlQuery.getType() to get 
the int value (this is a change
made after cocoon-2.0.3). The generated code is DBMS specific either way so there is 
nothing wrong with it referencing
a DBMS specific class.

SQLTransformer has to use reflection because its acting as an interpreter and 
executing the queries directly rather than generating
code to do so.
Regards,
        Neil.



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to