Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 59802 invoked from network); 29 Mar 2004 16:19:37 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 29 Mar 2004 16:19:37 -0000 Received: (qmail 57493 invoked by uid 500); 29 Mar 2004 16:19:20 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 57389 invoked by uid 500); 29 Mar 2004 16:19:19 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 57364 invoked from network); 29 Mar 2004 16:19:18 -0000 Received: from unknown (HELO outmx006.isp.belgacom.be) (195.238.2.99) by daedalus.apache.org with SMTP; 29 Mar 2004 16:19:18 -0000 Received: from [10.32.2.20] (177.7-201-80.adsl.skynet.be [80.201.7.177]) by outmx006.isp.belgacom.be (8.12.9/8.12.9/Skynet-OUT-2.21) with ESMTP id i2TGJDgI002057 for ; Mon, 29 Mar 2004 18:19:13 +0200 (envelope-from ) Mime-Version: 1.0 (Apple Message framework v613) In-Reply-To: <61C67D54412429409C0CD053D25DA429024B0033@EX2LUJMOMBX05> References: <61C67D54412429409C0CD053D25DA429024B0033@EX2LUJMOMBX05> Content-Type: multipart/alternative; boundary=Apple-Mail-12--809221532 Message-Id: From: Yves Vindevogel Subject: Re: XSP: problem generating computed attribute for root tag Date: Mon, 29 Mar 2004 18:19:53 +0200 To: users@cocoon.apache.org X-Mailer: Apple Mail (2.613) X-RAVMilter-Version: 8.4.3(snapshot 20030212) (outmx006.isp.belgacom.be) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --Apple-Mail-12--809221532 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; format=flowed You should always start with an XML element, not with I've experienced strange behaviour too when I immediatly started with=20 logic instead of an element On 29 Mar 2004, at 14:42, Wouter.DERUYCK@cec.eu.int wrote: > I have experienced some problems generating xml with some computed=20 > attributes in the root element. > > If I try to execute this: > > > > > xmlns:xsp-request=3D"http://apache.org/xsp/request/2.0" > > xmlns:esql=3D"http://apache.org/cocoon/SQL/v2" > > xmlns:xsp-session=3D"http://apache.org/xsp/session/2.0" > > xmlns:i18n=3D"http://apache.org/cocoon/i18n/2.1" > > create-session=3D"true"> > > =A0 > > > > > > String dummy =3D "aaa"; > > String s =3D (String)(request.getParameter("test")); > > > > > > s > > > > > > > > Execution result is an error because if you look at generated code,=20 > the request String object is generated as a class attibute and can't=20= > be initialize because the request object is null. > > : > > =A0 > > > Internal Server Error > > > Message: Language Exception > > Description: org.apache.cocoon.ProcessingException: Language=20 > Exception: org.apache.cocoon.components.language.LanguageException:=20 > Error while instantiating org\apache\cocoon\www\dummy_xsp:=20 > java.lang.NullPointerException > > Sender: org.apache.cocoon.servlet.CocoonServlet > > Source: Cocoon Servlet > > Request URI > > > dummy/bb > > > cause > > > java.lang.NullPointerException > > > request-uri > > > /cocoon/dummy/bb > > > full exception chain stacktrace > > > Original Exception:=20 > org.apache.cocoon.components.language.LanguageException: Error while=20= > instantiating org\apache\cocoon\www\dummy_xsp:=20 > java.lang.NullPointerException > > > =A0 > > Second try: > > Then I thought about moving the logic code after the root tag, and=20 > hoped my logic being moved in the generate method: > > > > > xmlns:xsp-request=3D"http://apache.org/xsp/request/2.0" > > xmlns:esql=3D"http://apache.org/cocoon/SQL/v2" > > xmlns:xsp-session=3D"http://apache.org/xsp/session/2.0" > > xmlns:i18n=3D"http://apache.org/cocoon/i18n/2.1" > > create-session=3D"true"> > > =A0 > > > > =A0 > > > > > > String dummy =3D "aaa"; > > String s =3D (String)(request.getParameter("test")); > > > > s > > > > > > > > =A0 > > =A0 > > This failed with a compilig error: > > =A0 > > > Internal Server Error > > > Message: Language Exception > > Description: org.apache.cocoon.ProcessingException: Language=20 > Exception: org.apache.cocoon.components.language.LanguageException:=20 > Error compiling dummy_xsp: ERROR 1=20 > (org\apache\cocoon\www\dummy_xsp.java): ... "", "key", "key", "CDATA",=20= > // start error (lines 298-298) "s cannot be resolved"=20 > String.valueOf(s) + " " // end error );=20 > this.contentHandler.startElement( ... Line 298, column 0: s cannot be=20= > resolved > > Sender: org.apache.cocoon.servlet.CocoonServlet > > Source: Cocoon Servlet > > Request URI > > > dummy/bb > > > cause > > > org.apache.cocoon.components.language.LanguageException: Error=20 > compiling dummy_xsp: > > ERROR 1 (org\apache\cocoon\www\dummy_xsp.java): > > ... > > "", > > "key", > > "key", > > "CDATA", > > // start error (lines 298-298) "s cannot be resolved" > > String.valueOf(s) + " " > > // end error > > ); > > this.contentHandler.startElement( > > ... > > Line 298, column 0: s cannot be resolved > > > =A0 > > This is because the generation of the attibute > > xspAttr.addAttribute( > > "", > > "key", > > "key", > > "CDATA", > > String.valueOf(s) + " " > > ); > > is done after the declaration of the s variable!!! > > If I move the code a little bit forward in the attribute tag I also=20 > experienced that problem. > > The only "turnaround" I found is putting an "artificial" root element=20= > like here under and remove it afterword but it causes other troubles > > in my following treatments: > > =A0 > > =A0 > > > > > xmlns:xsp-request=3D"http://apache.org/xsp/request/2.0" > > xmlns:esql=3D"http://apache.org/cocoon/SQL/v2" > > xmlns:xsp-session=3D"http://apache.org/xsp/session/2.0" > > xmlns:i18n=3D"http://apache.org/cocoon/i18n/2.1" > > create-session=3D"true"> > Met vriendelijke groeten, Bien =E0 vous, Kind regards, Yves Vindevogel Implements Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 Markt 18c - 9700 Oudenaarde - Tel: +32 (55) 30 55 76 Web: http://www.implements.be First they ignore you. Then they laugh at you. Then they fight you. =20= Then you win. Mahatma Ghandi. --Apple-Mail-12--809221532 Content-Transfer-Encoding: quoted-printable Content-Type: text/enriched; charset=ISO-8859-1 You should always start with an XML element, not with < =20 I've experienced strange behaviour too when I immediatly started with logic instead of an element On 29 Mar 2004, at 14:42, Wouter.DERUYCK@cec.eu.int wrote: = Arial0000,0000,FFFFI have experienced some problems generating xml with some computed attributes in the root element. = Arial0000,0000,FFFFIf I try to execute this: = Arial0000,0000,FFFF< = Arial0000,0000,FFFF< = Arial0000,0000,FFFFxmlns:xsp-request=3D"http://apache.org/xsp/request/2.0" = Arial0000,0000,FFFFxmlns:esql=3D"http://apache.org/cocoon/SQL/v2" = Arial0000,0000,FFFFxmlns:xsp-session=3D"http://apache.org/xsp/session/2.0" = Arial0000,0000,FFFFxmlns:i18n=3D"http://apache.org/cocoon/i18n/2.1" = Arial0000,0000,FFFFcreate-session=3D"true"> = Arial0000,0000,FFFF=A0 = Arial0000,0000,FFFF< = Arial0000,0000,FFFF< = Arial0000,0000,FFFFString dummy =3D "aaa"; = Arial0000,0000,FFFFString s =3D = (String)(request.getParameter("test")); = Arial0000,0000,FFFF< = Arial0000,0000,FFFF< = Arial0000,0000,FFFF<<s< = Arial0000,0000,FFFF< = Arial0000,0000,FFFF< = Arial0000,0000,FFFF< = Arial0000,0000,FFFFExecution result is an error because if you look at generated code, the request String object is generated as a class attibute and can't be initialize because the request object is null. = Arial0000,0000,FFFF : = Arial0000,0000,FFFF=A0 Times New = Roman0000,0000,FFFF<= bigger>Internal Server = Error Times New = Roman0000,0000,FFFFMessage: Language Exception Times New = Roman0000,0000,FFFFDescription: org.apache.cocoon.ProcessingException: Language Exception: org.apache.cocoon.components.language.LanguageException: Error while instantiating org\apache\cocoon\www\dummy_xsp: java.lang.NullPointerException Times New = Roman0000,0000,FFFFSender: org.apache.cocoon.servlet.CocoonServlet Times New = Roman0000,0000,FFFFSource: Cocoon Servlet Times New = Roman0000,0000,FFFFRequest URI Courier = New0000,0000,FFFFdummy/bb= Times New = Roman0000,0000,FFFFcause<= /color> Courier = New0000,0000,FFFFjava.lang.NullPoin= terException Times New = Roman0000,0000,FFFFrequest-uri Courier = New0000,0000,FFFF/cocoon/dummy/bb Times New = Roman0000,0000,FFFFfull exception chain stacktrace Courier = New0000,0000,FFFFOriginal Exception: org.apache.cocoon.components.language.LanguageException: Error while instantiating org\apache\cocoon\www\dummy_xsp: java.lang.NullPointerException = Arial0000,0000,FFFF=A0 = Arial0000,0000,FFFFSecond try: = Arial0000,0000,FFFFThen I thought about moving the logic code after the root tag, and hoped my logic being moved in the generate method: = Arial0000,0000,FFFF< = Arial0000,0000,FFFF< = Arial0000,0000,FFFFxmlns:xsp-request=3D"http://apache.org/xsp/request/2.0" = Arial0000,0000,FFFFxmlns:esql=3D"http://apache.org/cocoon/SQL/v2" = Arial0000,0000,FFFFxmlns:xsp-session=3D"http://apache.org/xsp/session/2.0" = Arial0000,0000,FFFFxmlns:i18n=3D"http://apache.org/cocoon/i18n/2.1" = Arial0000,0000,FFFFcreate-session=3D"true"> = Arial0000,0000,FFFF=A0 = Arial0000,0000,FFFF< = Arial0000,0000,FFFF=A0 = Arial0000,0000,FFFF< = Arial0000,0000,FFFF< = Arial0000,0000,FFFFString dummy =3D "aaa"; = Arial0000,0000,FFFFString s =3D = (String)(request.getParameter("test")); = Arial0000,0000,FFFF< = Arial0000,0000,FFFF<<s< = Arial0000,0000,FFFF< = Arial0000,0000,FFFF< = Arial0000,0000,FFFF< = Arial0000,0000,FFFF=A0 = Arial0000,0000,FFFF=A0 = Arial0000,0000,FFFFThis failed with a compilig error: = Arial0000,0000,FFFF=A0 Times New = Roman0000,0000,FFFF<= bigger>Internal Server = Error Times New = Roman0000,0000,FFFFMessage: Language Exception Times New = Roman0000,0000,FFFFDescription: org.apache.cocoon.ProcessingException: Language Exception: org.apache.cocoon.components.language.LanguageException: Error compiling dummy_xsp: ERROR 1 (org\apache\cocoon\www\dummy_xsp.java): ... "", "key", "key", "CDATA", // start error (lines 298-298) "s cannot be resolved" String.valueOf(s) + " " // end error ); this.contentHandler.startElement( ... Line 298, column 0: s cannot be resolved Times New = Roman0000,0000,FFFFSender: org.apache.cocoon.servlet.CocoonServlet Times New = Roman0000,0000,FFFFSource: Cocoon Servlet Times New = Roman0000,0000,FFFFRequest URI Courier = New0000,0000,FFFFdummy/bb= Times New = Roman0000,0000,FFFFcause<= /color> Courier = New0000,0000,FFFForg.apache.cocoon.= components.language.LanguageException: Error compiling dummy_xsp: Courier = New0000,0000,FFFFERROR 1 = (org\apache\cocoon\www\dummy_xsp.java): Courier = New0000,0000,FFFF... Courier = New0000,0000,FFFF"", Courier = New0000,0000,FFFF"key", Courier = New0000,0000,FFFF"key", Courier = New0000,0000,FFFF"CDATA",= Courier = New0000,0000,FFFF// start error (lines 298-298) "s cannot be = resolved" Courier = New0000,0000,FFFFString.valueOf(s) + " " Courier = New0000,0000,FFFF// end error Courier = New0000,0000,FFFF); Courier = New0000,0000,FFFFthis.contentHandle= r.startElement( Courier = New0000,0000,FFFF... Courier = New0000,0000,FFFFLine 298, column 0: s cannot be = resolved = Arial0000,0000,FFFF=A0 = Arial0000,0000,FFFFThis is because the generation of the attibute = Arial0000,0000,FFFF xspAttr.addAttribute( = Arial0000,0000,FFFF"", = Arial0000,0000,FFFF"key", = Arial0000,0000,FFFF"key", = Arial0000,0000,FFFF"CDATA", = Arial0000,0000,FFFFString.valueOf(s) + " " = Arial0000,0000,FFFF); = Arial0000,0000,FFFFis done after the declaration of the s = variable!!! = Arial0000,0000,FFFFIf I move the code a little bit forward in the attribute tag I also experienced that problem. = Arial0000,0000,FFFFThe only "turnaround" I found is putting an "artificial" root element like here under and remove it afterword but it causes other = troubles = Arial0000,0000,FFFFin my following treatments: = Arial0000,0000,FFFF =A0 = Arial0000,0000,FFFF=A0 = Arial0000,0000,FFFF< = Arial0000,0000,FFFF< = Arial0000,0000,FFFFxmlns:xsp-request=3D"http://apache.org/xsp/request/2.0" = Arial0000,0000,FFFFxmlns:esql=3D"http://apache.org/cocoon/SQL/v2" = Arial0000,0000,FFFFxmlns:xsp-session=3D"http://apache.org/xsp/session/2.0" = Arial0000,0000,FFFFxmlns:i18n=3D"http://apache.org/cocoon/i18n/2.1" = Arial0000,0000,FFFFcreate-session=3D"true"> Met vriendelijke groeten, Bien =E0 vous, Kind regards, Yves Vindevogel Implements Mail: yves.vindevogel@implements.be - Mobile: +32 (478) 80 82 91 Kempische Steenweg 206 - 3500 Hasselt - Tel-Fax: +32 (11) 43 55 76 Markt 18c - 9700 Oudenaarde - Tel: +32 (55) 30 55 76 Web: http://www.implements.be First they ignore you. Then they laugh at you. Then they fight you.=20 Then you win. Mahatma Ghandi. --Apple-Mail-12--809221532--