cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marco Spinetti" <m.spine...@pisa.iol.it>
Subject R: DOM ERROR
Date Wed, 25 Oct 2000 15:45:00 GMT
Hi,
I send you the file as attchment.
I want to use DOM because I must look for ( in the file xml)a text inside a
tag which depends from the parameter "segno".
Marco
m.spinetti@pisa.iol.it

----- Original Message -----
From: Robin Green <greenrd@hotmail.com>
To: <cocoon-users@xml.apache.org>
Sent: Wednesday, October 25, 2000 6:07 PM
Subject: Re: DOM ERROR


> marco <m.spinetti@pisa.iol.it> 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:
> >
> ><xsp:logic>
> >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&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>
>
> Pass in the request object as mentioned above:
> main (request)
>
> but you can't use <xsp:expr> for this since main() does not return
anything!
>
> ></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;
>
> 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.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>
>

Mime
View raw message