You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Chris Maloney <co...@chrismaloney.com> on 2005/05/16 14:06:19 UTC
Re: FOR-loop in xsp:logic section
Try wrapping your "xsp:logic" in some other element, like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:xsp-session="http://apache.org/xsp/session/2.0"
xmlns:esql="http://apache.org/cocoon/SQL/v2"
create-session="true">
<xsp:structure>
</xsp:structure>
<OtherElement>
<xsp:logic>
for (int i=0;i< 9; i++){
i=i+1;
}
</xsp:logic>
</OtherElement>
</xsp:page>
FWIW, it can help in debugging XSP problems to examine the ".java" file
that gets created. I'm using Cocoon 2.1.5.1, and that puts these
generated .java files into
build/webapp/WEB-INF/work/cocoon-files/org/apache/cocoon/www/.... I
think, in later versions, it puts them somewhere else, under a system
temp directory. In your case, search for getStatement_xsp.java (which
you can see from the error message, is the name of the .java file).
HTH,
Chris Maloney
Michael Milvich wrote:
> Hallo,
>
> i am using Cocoon 2.1.7, jdk 1.4 and tomcat 5.0.19.
>
> I would like to include in a xsp-page a small logic part and in this
> logic section a FOR loop.
> Everything works fine, only the FOR loop doesn't work. Here is my
> simple code:
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-request="http://apache.org/xsp/request/2.0"
> xmlns:xsp-session="http://apache.org/xsp/session/2.0"
> xmlns:esql="http://apache.org/cocoon/SQL/v2"
> create-session="true">
> <xsp:structure>
> </xsp:structure>
> <xsp:logic>
> for (int i=0;i< 9; i++){
> i=i+1;
> }
> </xsp:logic>
> </xsp:page>
>
> I get the following error when calling the xsp-page:
>
>> Error compiling getStatement_xsp: ERROR 1
>> (org\apache\cocoon\www\apples\xsp\getStatement_xsp.java): ...
>> XSPObjectHelper.xspExpr(contentHandler, obj); ; } // start error
>> (lines 237-237) "Syntax error on token "}", { expected after this
>> token" } // end error for (int i=0;i< 9; i++) i=i+1; ... ERROR 2
>> (org\apache\cocoon\www\apples\xsp\getStatement_xsp.java): ... ; } }
>> // start error (lines 239-239) "Syntax error on token(s), misplaced
>> construct(s)" for (int i=0;i< 9; i++) // end error i=i+1; /** ...
>> Line 237, column 0: Syntax error on token "}", { expected after this
>> token Line 239, column 0: Syntax error on token(s), misplaced
>> construct(s)
>
>
>
> My question is. How can I include a FOR or a WHILE loop in the
> xsp:logic section?
>
> Thanks for help in advance
>
> Michael Milvich
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For
> additional commands, e-mail: users-help@cocoon.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: FOR-loop in xsp:logic section
Posted by Michael Milvich <m....@gmx.de>.
Hallo,
thank you Chris for help. It's working!
I also I looked at the created *.java class and found out that cocoon is
doing something strange, when the additional elements are missing. Here
is the code:
XSPObjectHelper.xspExpr(contentHandler, obj);
;
}
}
for (int i=0;i< 9; i++)
i=i+1;
Is this a bug in cocoon?
regards
Michael Milvich
Chris Maloney wrote:
> Try wrapping your "xsp:logic" in some other element, like this:
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-request="http://apache.org/xsp/request/2.0"
> xmlns:xsp-session="http://apache.org/xsp/session/2.0"
> xmlns:esql="http://apache.org/cocoon/SQL/v2"
> create-session="true">
> <xsp:structure>
> </xsp:structure>
> <OtherElement>
> <xsp:logic>
> for (int i=0;i< 9; i++){
> i=i+1;
> }
> </xsp:logic>
> </OtherElement>
> </xsp:page>
>
> FWIW, it can help in debugging XSP problems to examine the ".java"
> file that gets created. I'm using Cocoon 2.1.5.1, and that puts these
> generated .java files into
> build/webapp/WEB-INF/work/cocoon-files/org/apache/cocoon/www/.... I
> think, in later versions, it puts them somewhere else, under a system
> temp directory. In your case, search for getStatement_xsp.java (which
> you can see from the error message, is the name of the .java file).
>
> HTH,
> Chris Maloney
>
>
> Michael Milvich wrote:
>
>> Hallo,
>>
>> i am using Cocoon 2.1.7, jdk 1.4 and tomcat 5.0.19.
>>
>> I would like to include in a xsp-page a small logic part and in this
>> logic section a FOR loop.
>> Everything works fine, only the FOR loop doesn't work. Here is my
>> simple code:
>>
>> <?xml version="1.0" encoding="iso-8859-1"?>
>> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp"
>> xmlns:xsp-request="http://apache.org/xsp/request/2.0"
>> xmlns:xsp-session="http://apache.org/xsp/session/2.0"
>> xmlns:esql="http://apache.org/cocoon/SQL/v2"
>> create-session="true">
>> <xsp:structure>
>> </xsp:structure>
>> <xsp:logic>
>> for (int i=0;i< 9; i++){
>> i=i+1;
>> }
>> </xsp:logic>
>> </xsp:page>
>>
>> I get the following error when calling the xsp-page:
>>
>>> Error compiling getStatement_xsp: ERROR 1
>>> (org\apache\cocoon\www\apples\xsp\getStatement_xsp.java): ...
>>> XSPObjectHelper.xspExpr(contentHandler, obj); ; } // start error
>>> (lines 237-237) "Syntax error on token "}", { expected after this
>>> token" } // end error for (int i=0;i< 9; i++) i=i+1; ... ERROR 2
>>> (org\apache\cocoon\www\apples\xsp\getStatement_xsp.java): ... ; } }
>>> // start error (lines 239-239) "Syntax error on token(s), misplaced
>>> construct(s)" for (int i=0;i< 9; i++) // end error i=i+1; /** ...
>>> Line 237, column 0: Syntax error on token "}", { expected after this
>>> token Line 239, column 0: Syntax error on token(s), misplaced
>>> construct(s)
>>
>>
>>
>>
>> My question is. How can I include a FOR or a WHILE loop in the
>> xsp:logic section?
>>
>> Thanks for help in advance
>>
>> Michael Milvich
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For
>> additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org