From cocoon-users-return-23683-apmail-xml-cocoon-users-archive=xml.apache.org@xml.apache.org Sun Sep 16 16:58:38 2001 Return-Path: Delivered-To: apmail-xml-cocoon-users-archive@xml.apache.org Received: (qmail 16506 invoked by uid 500); 16 Sep 2001 16:58:37 -0000 Mailing-List: contact cocoon-users-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-users@xml.apache.org Delivered-To: mailing list cocoon-users@xml.apache.org Received: (qmail 16462 invoked from network); 16 Sep 2001 16:58:37 -0000 Message-ID: <005301c13ed0$b28eb0a0$663638d5@wanadoo.fr> Reply-To: "cib" From: "cib" To: References: <001b01c13edd$2264f220$0100a8c0@gigarisssa> Subject: Re: Xsp logic simpler error Date: Sun, 16 Sep 2001 18:57:40 +0200 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0050_01C13EE1.75774900" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ------=_NextPart_000_0050_01C13EE1.75774900 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thanks to Luis Gois for answering it now says: "No method matching main() found in inner class = org.apache.cocoon.www.pages.make1_xsp. make_xsl." I really don't know why there is a space between make1_xsp. and = make_xsl. Is it normal? ******* Here is my code for make1.xsp ******* java.io.* class make_xsl { public void main(String[] args) throws IOException { FileReader entree =3D new = FileReader(("http//:localhost/cocoon/test/make.xsl")); FileWriter sortie =3D new FileWriter("output.txt"); int c; while ( (c =3D entree.read()) !=3D -1 ) =20 sortie.write(c); =20 sortie.close(); =20 entree.close(); =20 } } make_xsl anObject =3D new make_xsl(); anObject.main(); If you see this, it works. Surely I didn't put the anObject call at the right place. My java is = rather experimental. Thanks again. ******* I ADD THE CODE OF make1_xsp.java (I strip the code of usual imports): ******* package org.apache.cocoon.www.pages; import java.io.*; /** * Generated by XSP. Edit at your own risk, :-) */ public class make1_xsp extends XSPGenerator { static { dateCreated =3D 1000658859410L; dependencies =3D new File[]{ }; } /* Built-in parameters available for use */ // context - ServletContext // request - HttpServletRequest // response - HttpServletResponse // parameters - parameters defined in the sitemap /* User Class Declarations */ class EsqlConnection { Connection connection =3D null; String dburl =3D null; java.util.Properties info =3D new java.util.Properties(); int use_limit_clause =3D 0; static final int LIMIT_CLAUSE_POSTGRESQL =3D 1; static final int LIMIT_CLAUSE_MYSQL =3D 2; } class EsqlQuery { String query; Statement statement; PreparedStatement prepared_statement; ResultSet resultset; ResultSetMetaData resultset_metadata; /** the position of the current row in the resultset **/ int position =3D -1; int max_rows =3D -1; int skip_rows =3D 0; boolean results; } private final String getAscii(ResultSet set, String column) { InputStream asciiStream =3D null; byte[] buffer =3D null; try { Clob dbClob =3D set.getClob(column); int length =3D (int) dbClob.length(); asciiStream =3D new BufferedInputStream(dbClob.getAsciiStream()); buffer =3D new byte[length]; asciiStream.read(buffer); asciiStream.close(); } catch (Exception e) { throw new RuntimeException("Error getting clob data: " + e.getMessage()); } finally { if (asciiStream !=3D null) try { asciiStream.close(); } catch (Exception ase) { throw new RuntimeException( "Error closing clob stream: " + ase.getMessage()); } } if (buffer =3D=3D null) return ""; return new String(buffer); } class make_xsl { public void main(String[] args) throws IOException { FileReader entree =3D new = FileReader(("http//:localhost/cocoon/test/make.xsl")); FileWriter sortie =3D new FileWriter("output.txt"); int c; while ((c =3D entree.read()) !=3D -1) sortie.write(c); sortie.close(); entree.close(); } } /** * Generate XML data. */ public void generate() throws SAXException { this.contentHandler.startDocument(); AttributesImpl xspAttr =3D new AttributesImpl(); this.contentHandler.startPrefixMapping("xspdoc", = "http://apache.org/cocoon/XSPDoc/v1"); this.contentHandler.startPrefixMapping("esql", = "http://apache.org/cocoon/SQL/v2"); this.contentHandler.startPrefixMapping("xsp", = "http://apache.org/xsp"); this.contentHandler.startElement("", "page", "page", xspAttr); xspAttr.clear(); Stack _esql_connections =3D new Stack(); EsqlConnection _esql_connection =3D null; Stack _esql_queries =3D new Stack(); EsqlQuery _esql_query =3D null; SQLException _esql_exception =3D null; StringWriter _esql_exception_writer =3D null; this.characters("\n\n"); make_xsl anObject =3D new make_xsl(); anObject.main(); this.characters("\n\nIf you see this, it works.\n "); this.contentHandler.endElement("", "page", "page"); this.contentHandler.endPrefixMapping("xspdoc"); this.contentHandler.endPrefixMapping("esql"); this.contentHandler.endPrefixMapping("xsp"); this.contentHandler.endDocument(); } } ----- Original Message -----=20 From: Luis Gois=20 To: cocoon-users@xml.apache.org ; vendo1@caramail.com=20 Sent: Sunday, September 16, 2001 8:26 PM Subject: Re : Xsp logic simpler error=20 You've made an inner class but you're calling it as a method! Try this : make_xsl anObject =3D new make_xsl(); anObject.main(); you main() method won't be called as you instatiate your make_xsl = class, like it would happen if this was your program's starting/main = class. Luis Gois ------=_NextPart_000_0050_01C13EE1.75774900 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thanks to Luis Gois for = answering
it now says:
"No method matching main() found in inner class=20 org.apache.cocoon.www.pages.make1_xsp. make_xsl."
I really don't know why there is a = space between=20 make1_xsp. and  make_xsl. = Is it=20 normal?
 
*******
Here is my code for = make1.xsp
*******
<?xml version=3D"1.0"=20 encoding=3D"ISO-8859-1"?>
 
<xsp:page
        =  =20 language=3D"java"
        &nbs= p;=20 xmlns:xsp=3D"http://apache.org/xsp"
  =        =20 xmlns:esql=3D"http://apache.org/cocoon/SQL/v2<= /A>">
 
<xsp:structure>
 =20 <xsp:include>java.io.*</xsp:include>
</xsp:structure>= ;
 
<xsp:logic>
class make_xsl = {
 =20 public void main(String[] args) throws IOException {
 FileReader = entree=20 =3D new=20 FileReader(("http//:localhost/cocoon/test/make.xsl"));
  Fil= eWriter=20 sortie =3D new FileWriter("output.txt");
 int c;
 while = ( (c =3D=20 entree.read()) !=3D -1=20 )            = =20
sortie.write(c);         = ;   =20
sortie.close();        =20
entree.close();      =
    =20 }
}
</xsp:logic>

  <page>
 
<xsp:logic>
    make_xsl anObject =3D new=20 make_xsl();
    = anObject.main();
</xsp:logic>
 
If you see this, it works.
 =20 </page>
</xsp:page>
 
 
Surely I didn't put the anObject call at the right place. My java = is rather=20 experimental.
Thanks again.
 
*******
I ADD THE CODE OF make1_xsp.java (I strip the code of usual=20 imports):
*******
 
 
package = org.apache.cocoon.www.pages;
import java.io.*;

/**
 * Generated by XSP. Edit at your own risk,=20 :-)
 */
public class make1_xsp extends XSPGenerator {
 
  static {
    dateCreated =3D=20 1000658859410L;
    dependencies =3D new=20 File[]{
          &n= bsp;       =20 };
  }
 
  /* Built-in parameters available for use */
  //=20 context    - ServletContext
  //=20 request    - HttpServletRequest
  // = response  =20 - HttpServletResponse
  // parameters - parameters defined in = the=20 sitemap
 
  /* User Class Declarations */
 
  class EsqlConnection {
 
    Connection connection =3D = null;
   =20 String dburl =3D null;
    java.util.Properties info = =3D new=20 java.util.Properties();
    int use_limit_clause =3D=20 0;
    static final int LIMIT_CLAUSE_POSTGRESQL =3D=20 1;
    static final int LIMIT_CLAUSE_MYSQL =3D = 2;
 =20 }
  class EsqlQuery {
    String=20 query;
    Statement statement;
   =20 PreparedStatement prepared_statement;
    ResultSet=20 resultset;
    ResultSetMetaData=20 resultset_metadata;
    /** the position of the = current row in=20 the resultset **/
    int position =3D = -1;
   =20 int max_rows =3D -1;
    int skip_rows =3D=20 0;
    boolean results;
  }
 
  private final String getAscii(ResultSet set, String column)=20 {
    InputStream asciiStream =3D = null;
   =20 byte[] buffer =3D null;
 
    try {
      Clob = dbClob =3D=20 set.getClob(column);
      int length =3D = (int)=20 dbClob.length();
      asciiStream =3D new=20 BufferedInputStream(dbClob.getAsciiStream());
    =  =20 buffer =3D new byte[length];
     =20 asciiStream.read(buffer);
     =20 asciiStream.close();
    } catch (Exception e)=20 {
      throw new RuntimeException("Error = getting=20 clob data: "=20 +
           &n= bsp;           &nb= sp;        =20 e.getMessage());
    }
    finally { = if=20 (asciiStream !=3D=20 null)
          &nbs= p;  =20 try=20 {
           &n= bsp;     =20 asciiStream.close();
        &= nbsp;    =20 } catch (Exception ase)=20 {
           &n= bsp;     =20 throw new=20 RuntimeException(
        &nbs= p;          =20 "Error closing clob stream: " +=20 ase.getMessage());
        &nb= sp;      =20 }
           =20 }
    if (buffer =3D=3D = null)
     =20 return "";
 
    return new String(buffer);
  }
 
  class make_xsl {
    public void = main(String[]=20 args) throws IOException {
      FileReader = entree =3D=20 new=20 FileReader(("http//:localhost/cocoon/test/make.xsl"));
  &nb= sp;  =20 FileWriter sortie =3D new=20 FileWriter("output.txt");
      int=20 c;
      while ((c =3D entree.read()) !=3D=20 -1)
       =20 sortie.write(c);
     =20 sortie.close();
     =20 entree.close();
    }
  }
 

  /**
   * Generate XML data.
   = */
  public void generate() throws SAXException = {
   =20 this.contentHandler.startDocument();
    = AttributesImpl=20 xspAttr =3D new AttributesImpl();
 
 
 
    this.contentHandler.startPrefixMapping("xspdoc", = "http://apache.org/cocoon/XSPD= oc/v1");
 
    this.contentHandler.startPrefixMapping("esql", = "http://apache.org/cocoon/SQL/v2<= /A>");
 
    this.contentHandler.startPrefixMapping("xsp", = "http://apache.org/xsp");
 

    this.contentHandler.startElement("", "page", = "page",=20 xspAttr);
 
    xspAttr.clear();
 

    Stack _esql_connections =3D new=20 Stack();
    EsqlConnection _esql_connection =3D=20 null;
    Stack _esql_queries =3D new=20 Stack();
    EsqlQuery _esql_query =3D=20 null;
    SQLException _esql_exception =3D=20 null;
    StringWriter _esql_exception_writer =3D = null;
 
    this.characters("\n\n");
 
    make_xsl anObject =3D new=20 make_xsl();
    anObject.main();
 
    this.characters("\n\nIf you see this, it = works.\n =20 ");
 

    this.contentHandler.endElement("", "page",=20 "page");
 

   =20 this.contentHandler.endPrefixMapping("xspdoc");
 
    = this.contentHandler.endPrefixMapping("esql");
 
    = this.contentHandler.endPrefixMapping("xsp");
 

    this.contentHandler.endDocument();
  = }
}
 

 
----- Original Message -----
From:=20 Luis = Gois
Sent: Sunday, September 16, = 2001 8:26=20 PM
Subject: Re : Xsp logic simpler = error=20

You've made an inner class but you're = calling it=20 as a method!
 
Try this :
 
<xsp:logic>
    make_xsl anObject = =3D new=20 make_xsl();
    = anObject.main();
</xsp:logic>
 
you main() method won't be called as = you=20 instatiate your make_xsl class, like it would happen if this was your=20 program's starting/main class.
 
Luis = Gois
------=_NextPart_000_0050_01C13EE1.75774900--