You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Per Kreipke <pe...@onclave.com> on 2002/09/10 00:21:08 UTC
XSP bug: can get generate() to skip elements using java 'if's
The following XSP snippet will cause an ArrayIndexOutOfBoundsException in
Cocoon 2.0.3 because the start of the outer element is never emitted to the
SAX stream.
XSP Snippet:
<xsp:page ....>
<page>
<xsp:logic>
if (!request.isUserInRole("root"))
{
<xsp:attribute name="security-error">Not authorized</xsp:attribute>
}
else
{
</xsp:logic
<!-- Build the page if authorized -->
<content />
<xsp:logic>
}
</xsp:logic>
</page>
</xsp:page>
Generated Java code:
if (!request.isUserInRole("root"))
{
xspAttr.addAttribute("", "security-error", "security-error", "CDATA", "Not
authorized");
}
else
{
this.contentHandler.startElement("", "page", "page", xspAttr);
xspAttr.clear();
}
this.contentHandler.endElement("", "page", "page");
E.g. the start code for <page> isn't emitted. And I can't find a workaround:
neither emitting characters or another element inside the 'if' makes it
emit.
Per
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
RE: XSP bug: can get generate() to skip elements using java 'if's
Posted by Per Kreipke <pe...@onclave.com>.
Note: in xsp.xsl, the topmost non-xsp element is handled specially but this
error still occurs if you nest like this:
<page>
<foo>
<xsp:logic>if (...) {
<xsp:attribute...>
}
else
{
</xsp:logic>
...
<xsp:logic>
}
</xsp:logic>
</foo>
</page>
The culprit is the <xsp:attribute>. If I comment it out, the error doesn't
happen.
Per
> The following XSP snippet will cause an ArrayIndexOutOfBoundsException in
> Cocoon 2.0.3 because the start of the outer element is never
> emitted to the
> SAX stream.
>
> XSP Snippet:
>
>
> <xsp:page ....>
>
> <page>
> <xsp:logic>
> if (!request.isUserInRole("root"))
> {
> <xsp:attribute name="security-error">Not authorized</xsp:attribute>
> }
> else
> {
> </xsp:logic
>
> <!-- Build the page if authorized -->
> <content />
>
> <xsp:logic>
> }
> </xsp:logic>
> </page>
>
> </xsp:page>
>
>
>
>
> Generated Java code:
>
> if (!request.isUserInRole("root"))
> {
> xspAttr.addAttribute("", "security-error", "security-error",
> "CDATA", "Not
> authorized");
> }
> else
> {
> this.contentHandler.startElement("", "page", "page", xspAttr);
> xspAttr.clear();
>
> }
>
> this.contentHandler.endElement("", "page", "page");
>
>
>
> E.g. the start code for <page> isn't emitted. And I can't find a
> workaround:
> neither emitting characters or another element inside the 'if' makes it
> emit.
>
> Per
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>