Torsten Curdt wrote:

>Shouldn't the following construct work?
>
> ...
> <tag>
>    <xsp:logic>
>       try {
>
>         <ns:list>
>           Collection list = ...
>
>           for (Iterator iterator = list.iterator(); iterator.hasNext();) {
>             MyObj o = (MyObj) iterator.next();
>
>             <ns:MyObj>
>               <ns:name>o.getName()</ns:name>
>             </ns:MyObj>
>
>           }
>         </ns:list>
>
>       }
>       catch(Exception e) {
>         <xsp:content>Error: <xsp:expr>String.valueOf(e)</xsp:expr></xsp:content>
>       }
>    </xsp:logic>
> </tag>
> ...
>
>Referring to some old C1 documentation http://xml.apache.org/cocoon1/xsp.html
>(paragraph "logic tags") this should work.
>And I think this should work the same way in C2!
>
You need to open a new <xsp:logic> inside <ns:list> : the scope of Java 
code in <xsp:logic> is limited to text nodes that are its _direct_ 
 children. Also, "o.getName()" should be enclosed by an <xsp:expr>. So 
the above snippet should be written as follows :

<tag>
  <xsp:logic>
    try {
      <ns:list>
        <xsp:logic>
          Collection list = ...
          for (Iterator iterator = list.iterator(); iterator.hasNext();) {
            MyObj o = (MyObj) iterator.next();
              <ns:MyObj>
                <ns:name><xsp:expr>o.getName()</xsp:expr></ns:name>
              </ns:MyObj>
          }
        </xsp:logic>
      </ns:list>
    }
    catch(Exception e) {
      <xsp:content>Error: 
<xsp:expr>String.valueOf(e)</xsp:expr></xsp:content>
    }
  </xsp:logic>
</tag>

So I'm not sure there is a wrong behaviour in the engine.
Sylvain

>
>One could use <xsp:element> (like e.g. esql does) to work around this.
>But that's a not quite nice sollution. Can we aggree that this should
>work?
>
>Unfortunately the current implementation will treat any java code
>within a tag inside the xsp logic tag as text nodes - not as java.
>
>If we can aggree that this behaviour is wrong I'd like to change
>the xsp.xsl accordingly.
>--
>Torsten
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to