Return-Path: Mailing-List: contact cocoon-users-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-users@xml.apache.org Received: (qmail 21420 invoked from network); 25 Oct 2000 15:07:57 -0000 Received: from f265.law4.hotmail.com (HELO hotmail.com) (216.33.148.143) by locus.apache.org with SMTP; 25 Oct 2000 15:07:57 -0000 Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 25 Oct 2000 08:07:30 -0700 Received: from 148.88.0.10 by lw4fd.law4.hotmail.msn.com with HTTP; Wed, 25 Oct 2000 15:07:30 GMT X-Originating-IP: [148.88.0.10] From: "Robin Green" To: cocoon-users@xml.apache.org Subject: Re: DOM ERROR Date: Wed, 25 Oct 2000 16:07:30 BST Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 25 Oct 2000 15:07:30.0823 (UTC) FILETIME=[4BBEF970:01C03E95] X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N marco wrote: >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: > > >public void main () { If you need to use the request object in a method, then you need to pass it in: public void main (HttpServletRequest request) { > 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(); I think this should be Document doc = xspParser.parse("/usr/local..."); > 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<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; >} > > > >Therefore I try to call the Main () function: > > > >main() Pass in the request object as mentioned above: main (request) but you can't use for this since main() does not return anything! > > > >However the Cocoon returns me the following mistakes: > >

Error found handling the request.

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

These errors are happening before the main method in your XML. Please show 
us the full file.

>Can I use DOM in a xsp page?

Sure. But maybe you don't need to. Please explain what you're trying to do.



_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.