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 <m....@pisa.iol.it> on 2000/10/25 16:48:02 UTC

DOM ERROR

Hi,
I have tried to use the DOM inside Xsp to do the Parsing of the Xml file
to which the Sheet style is associate. The part in which I do the
Parsing is the following:

<xsp:logic>
public void main () {
 String segno = request.getParameter("segnou");
 String scelta = request.getParameter("sceltau");
 try {

xspParser.parse("/usr/local/jakarta-tomcat/webapps/cocoon/prova31.xml");

  Document doc = xspParser.getDocument();
  analizza(doc);
 } catch (Exception e) {
  System.err.println("ERRORE NEL PARSING:"+e.getMessage() );
 }
}

public String analizza ( Document doc) {
 String err = "Non trovata nessuna corrispondenza";
 boolean trovato = false;
 Element elem = doc.getDocumentElement();
 NodeList nl = elem.getElementsByTagName("Segno");
 for ( int i=0; i&lt;nl.getLength(); i++) {
  Element segno = (Element)nl.item(i);
  NodeList nl1 = segno.getElementsByTagName("Zodiaco");
  Node zodiaco = nl1.item(0);
  if (
(((CharacterData)zodiaco.getFirstChild()).getData()).equals(segno))
trovato=true;
  if (trovato) {
   trovato=false;
   NodeList nl2 = segno.getElementsByTagName("Generale");
   Element generale = (Element)nl2.item(0);
   NodeList nl3 = generale.getElementsByTagName("Descrizione");
   Node descrizione = nl3.item(0);
   String s = (((CharacterData)descrizione.getFirstChild()).getData());
   return s;
  }
 }
 return err;
}

</xsp:logic>

Therefore I try to call the Main () function:

<xsl:when test="$sceltau='generale'">
<CORPO>
<xsp:expr>main()</xsp:expr>
</CORPO>
</xsl:when>

However the Cocoon returns me the following mistakes:

<h3 align="center">Error found handling the request.</h3>
<blockquote><pre>java.lang.Exception: XSP Java Compiler: Compilation
failed for _prova31.java
64: '}' expected.
    xspParentNode.appendChild(xspCurrentNode);
                                              ^
67: Statement expected.
public void main () {
^
102: Identifier expected.
    xspParentNode = xspCurrentNode;
                 ^
3 errors


 at
org.apache.cocoon.processor.xsp.language.java.XSPJavaProcessor.compile(XSPJavaProcessor.java:141)

 at
org.apache.cocoon.processor.xsp.XSPProcessor.process(XSPProcessor.java:489)

 at org.apache.cocoon.Engine.handle(Engine.java:359)
 at org.apache.cocoon.Cocoon.service(Cocoon.java:167)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
 at
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)

 at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
 at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java,
Compiled Code)
 at
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java,
Compiled Code)
 at java.lang.Thread.run(Thread.java, Compiled Code)
</pre></blockquote>
      </td>     </tr>     <tr>      <td width="100%"
bgcolor="#FFFFFF">       <strong>Warning</strong>: this page has been
dynamically generated.      </td>     </tr>    </table>   </td>  </tr>
</table> </center> <p align="center">   <font size="-1">   Copyright (c)
1999-2000 <a href="http://xml.apache.org">The Apache XML
Project</a>.<br>   All rights reserved.   </font> </p> </body> </html>
][Data Length: 2063][HTTP Status: 200][Mime Type: text/html][CharSet:
null][HTTP Message: OK][URL:
http://localhost:8080/cocoon/prova31.xml?segnou=Toro&sceltau=generale][HeaderList:
date: Wed, 25 Oct 2000 14:33:33 GMT
content-language: en

Why?
Where are my errors?
Can I use DOM in a xsp page?
Marco
m.spinetti@pisa.iol.it