cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject Re: DOM ERROR
Date Wed, 25 Oct 2000 16:07:30 GMT
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.


Mime
View raw message