cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Pauck <pa...@wmd.de>
Subject Combining esql and other logicsheets with class-level logic
Date Thu, 05 Oct 2000 09:07:09 GMT
I've a problem when using esql with two other logicsheets
that include class-level code. The generated Java code contains
duplicate declarations then resulting in this error:
 
  java.lang.Exception: XSP Java Compiler: Compilation failed for _test02.java
  143: Duplicate variable declaration: Stack _esql_sessions was Stack _esql_sessions
     Stack _esql_sessions = new Stack();
                          ^
  144: Duplicate variable declaration: EsqlSession _esql_session was EsqlSession _esql_session
     EsqlSession _esql_session = null;
                               ^

Here's a simplified sample:

First my XSP document:

  <?xml version="1.0"?>
  <?cocoon-process type="xsp"?>
  <?xml-logicsheet href="lib1.xsl"?>
  <?xml-logicsheet href="lib2.xsl"?>
  <?xml-logicsheet href="resource://org/apache/cocoon/processor/xsp/library/sql/esql.xsl"?>

  <xsp:page
    language="java"
    xmlns:esql="http://apache.org/cocoon/SQL/v2"
    xmlns:xsp="http://www.apache.org/1999/XSP/Core"
    xmlns:lib1="http://www.wmd.de/2000/XSP/lib1"
    xmlns:lib2="http://www.wmd.de/2000/XSP/lib2"
  >

    <page>
      <esql:execute-query>
        <esql:driver>postgresql.Driver</esql:driver>
        <esql:dburl>jdbc:postgresql://localhost/test</esql:dburl>
        <esql:query>select * from whatever</esql:query>
        <esql:results>
        </esql:results>
      </esql:execute-query>
    </page>

  </xsp:page>

The first logicsheet:

  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0"
    xmlns:xsp="http://www.apache.org/1999/XSP/Core"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:lib1="http://www.wmd.de/2000/XSP/lib1"
  >

    <xsl:template match="xsp:page">
      <xsp:page>
        <xsl:apply-templates select="@*"/>
        <xsp:logic>
          private String do1(String string) {
            return "do1";
          }
        </xsp:logic>
        <xsl:apply-templates/>
      </xsp:page>
    </xsl:template>

    <xsl:template match="@*|*|text()|processing-instruction()">
      <xsl:copy>
        <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
      </xsl:copy>
    </xsl:template>

  </xsl:stylesheet>

The second logicsheet:

  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0"
    xmlns:xsp="http://www.apache.org/1999/XSP/Core"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:lib2="http://www.wmd.de/2000/XSP/lib2"
  >

    <xsl:template match="xsp:page">
      <xsp:page>
        <xsl:apply-templates select="@*"/>
        <xsp:logic>
          private String do2(String string) {
            return "do2";
          }
        </xsp:logic>
        <xsl:apply-templates/>
      </xsp:page>
    </xsl:template>

    <xsl:template match="@*|*|text()|processing-instruction()">
      <xsl:copy>
        <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
      </xsl:copy>
    </xsl:template>

  </xsl:stylesheet>

The problem seems to be caused by this template rule in esql.xsl:

  <xsl:template match="xsp:page/*">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsp:logic>
        Stack _esql_sessions = new Stack();
        EsqlSession _esql_session = null;
      </xsp:logic>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

What am I missing?

	Marco

Mime
View raw message