cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <jheini...@virbus.de>
Subject Re: Possible bug in XSP generator
Date Thu, 20 Nov 2003 10:16:21 GMT
Antonio Gallardo wrote:
> Try this:
> 
> <xsp:logic>
>   for (java.util.Iterator it = ajs.getMods().iterator(); it.hasNext(); ) {
> </xsp:logic>
>   <xsp:expr>it.next().toString()</xsp:expr><br/>
> <xsp:logic>
>   }
> </xsp:logic>

Uh, that's ugly! I feel reminded to println("<html><head>") code! I much 
more like David's approach using an additional <span>.

The reason for this XSP bug is the stylesheet. Around line 400 there is a 
template

<xsl:template match="xsp:expr">
   <xsl:choose>
     <xsl:when test="namespace-uri(..) = $xsp-uri and local-name(..) !=
                     'content' and local-name(..) != 'element'">
       <!--
            Expression is nested inside another XSP tag:
            preserve its Java type
       -->
       (<xsl:value-of select="."/>)
     </xsl:when>
     <xsl:when test="string-length(.) = 0">
       <!-- Do nothing -->
     </xsl:when>
     <xsl:otherwise>
       <!-- Output the value as elements or character data depending on its
            type -->
       XSPObjectHelper.xspExpr(contentHandler, <xsl:value-of select="."/>);
     </xsl:otherwise>
   </xsl:choose>
</xsl:template>

As you can see the first option tests for a surrounding XSP element as 
xsp:logic is one (and probably also your parent element of xsp:logic, this 
is why Antonio's approach also fails). But I don't know what exactly is the 
use case for this. Maybe somebody else can shed some light on this?

Joerg

> Carmona Perez, David dijo:
> 
>>Hi all,
>>
>>I have this snippet in an XSP file:
>>
>><xsp:logic>
>>      for (java.util.Iterator it = ajs.getMods().iterator(); it.hasNext();
>>) {
>>      String mod = it.next().toString();
>>            <xsp:expr>mod</xsp:expr><br/>
>>      }
>></xsp:logic>
>>
>>and the following code is generated:
>>
>>for (java.util.Iterator it = ajs.getMods().iterator(); it.hasNext(); ) {
>>                        String mod = it.next().toString();
>>(mod)
>>this.contentHandler.startElement("", "br", "br", xspAttr);
>>    xspAttr.clear();
>>            }
>>
>>
>>I think that the right code would be:
>>
>>for (java.util.Iterator it = ajs.getMods().iterator(); it.hasNext(); ) {
>>                        String mod = it.next().toString();
>>this.characters(mod);                           <------------------------
>>this.contentHandler.startElement("", "br", "br", xspAttr);
>>    xspAttr.clear();
>>            }
>>
>>Is this really a bug of the XSP generator?
>>--------
>>David

-- 
System Development
VIRBUS AG
Fon  +49(0)341-979-7419
Fax  +49(0)341-979-7409
joerg.heinicke@virbus.de
www.virbus.de


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message