You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Marco Pauck <pa...@wmd.de> on 2000/10/05 11:07:09 UTC

Combining esql and other logicsheets with class-level logic

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

Howto FP taglib and XPath.

Posted by Konstantin Piroumian <KP...@flagship.ru>.
Dear all!

I need to load a node-set from XML file and the XPath to the node list is
generated from the request.
But I cannot find the correct expression to load it.
This is from my XSP file:
<!-- I am trying to load a list from the given range (skip+1, rangeEnd) -->
  <fp:resource id="subs">
   <fp:resource-file>subscribers-db.xml</fp:resource-file>
   <fp:resource-node>/page/client/subscribers/subscriber[position() &gt;
<xsp:expr>skip</xsp:expr> and position() &lt;
<xsp:expr>rangeEnd</xsp:expr>]</fp:resource-node>
  </fp:resource>

Then, I need to place it here:

<subscribers>
    <fp:read select="*" from="subs" as="node"/>
   </subscribers>

And this does not work.
I thank that the error is in the * sign - cause it corresponds to children
of the current node.
When I use '.' - current node - it displays onlu the first item in the list.
Other XPath expression does not work (following-sibling, self, etc).

I will be very thankful for any help.

Regards,
  Konstantin Piroumian.
kpiroumian@flagship.ru


Re: Combining esql and other logicsheets with class-level logic

Posted by Marco Pauck <pa...@wmd.de>.
Donald Ball wrote:
> 
> On Thu, 5 Oct 2000, Marco Pauck wrote:
> 
> > 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;
> 
> thank you very much for the simplified example. i've checked in a newly
> patched version of esql that should fix this.

Yes, is works! Thanks a lot!

	Marco

Re: Combining esql and other logicsheets with class-level logic

Posted by Donald Ball <ba...@webslingerZ.com>.
On Thu, 5 Oct 2000, Marco Pauck wrote:

> 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;

thank you very much for the simplified example. i've checked in a newly
patched version of esql that should fix this.

- donald


Re: Combining esql and other logicsheets with class-level logic

Posted by Donald Ball <ba...@webslingerZ.com>.
On Thu, 5 Oct 2000, Marco Pauck wrote:

> 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?

nothing, i think you've found yourself a bona-fide bug. i'll be working on
this shortly.

- donald