I've experienced strange behaviour too when I immediatly started with logic instead of an element
On 29 Mar 2004, at 14:42, [EMAIL PROTECTED] wrote:
I have experienced some problems generating xml with some computed attributes in the root element.Met vriendelijke groeten,
If I try to execute this:
<?xml version="1.0" encoding="UTF-8"?>
<xsp:page xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:esql="http://apache.org/cocoon/SQL/v2"
xmlns:xsp-session="http://apache.org/xsp/session/2.0"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
create-session="true">
�
<!-- this is working fine -->
<xsp:logic>
String dummy = "aaa";
String s = (String)(request.getParameter("test"));
</xsp:logic>
<dum2>
<xsp:attribute name="key"><xsp:expr>s</xsp:expr>
</xsp:attribute>
</dum2>
</xsp:page>
Execution 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.
:
�
Internal Server Error
Message: Language Exception
Description: org.apache.cocoon.ProcessingException: Language Exception: org.apache.cocoon.components.language.LanguageException: Error while instantiating org\apache\cocoon\www\dummy_xsp: 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: org.apache.cocoon.components.language.LanguageException: Error while instantiating org\apache\cocoon\www\dummy_xsp: java.lang.NullPointerException
�
Second try:
Then I thought about moving the logic code after the root tag, and hoped my logic being moved in the generate method:
<?xml version="1.0" encoding="UTF-8"?>
<xsp:page xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:esql="http://apache.org/cocoon/SQL/v2"
xmlns:xsp-session="http://apache.org/xsp/session/2.0"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
create-session="true">
�
<!-- this is working fine -->
�
<dum2>
<xsp:logic>
String dummy = "aaa";
String s = (String)(request.getParameter("test"));
</xsp:logic>
<xsp:attribute name="key"><xsp:expr>s</xsp:expr>
</xsp:attribute>
</dum2>
</xsp:page>
�
�
This failed with a compilig error:
�
Internal Server Error
Message: Language Exception
Description: 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
Sender: org.apache.cocoon.servlet.CocoonServlet
Source: Cocoon Servlet
Request URI
dummy/bb
cause
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
�
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 experienced that problem.
The only "turnaround" I found is putting an "artificial" root element like here under and remove it afterword but it causes other troubles
in my following treatments:
�
�
<?xml version="1.0" encoding="UTF-8"?>
<xsp:page xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:esql="http://apache.org/cocoon/SQL/v2"
xmlns:xsp-session="http://apache.org/xsp/session/2.0"
xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
create-session="true">
Bien � vous,
Kind regards,
Yves Vindevogel
Implements
Mail: [EMAIL PROTECTED] - 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
<x-tad-smaller>
First they ignore you. Then they laugh at you. Then they fight you. Then you win.
Mahatma Ghandi.</x-tad-smaller>
