cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oceatoon <t.katelb...@systheo.com>
Subject Re: Help: XPath to Jexl
Date Tue, 21 Sep 2004 10:22:51 GMT
Sylvain Wallez wrote:

> oceatoon wrote:
> 
>>Hi everyone
>>
>>I am having trouble retreiving an attribute in jexl.
>>In jxpath, I can retreive it like this #{./description/@maxoc}
>>but ${description.maxoc} doesn't work, can someone guide me please??
>>  
>>
> 
> Jexl is a JavaBeans-oriented expression language. So you can't access
> attributes in an XML document using Jexl, except by using the DOM API
> (e.g. "${description.getAttribute("maxoc")}"). JXPath, on the contrary,
> traverses both DOM and JavaBeans hierarchies.
> 
> So in that particular case, using JXPath is the IMO the appropriate
> choice.
> 
> Sylvain
> 
Merci Sylvain, but I got a problem to your solution probably related to my
structure???

I absolutely agree with you and I started using JXPath, but unfortunetly I
haven't managed to get the JXTemplate jx:forEach 'end' 'begin' tags to work
with JXPath, nore the jx:macro??? which got me to jexl

my problem here is that , the jexl is in a forEach which is itself is
looping on a forEach, so my jexl call is relative to the first forEach
context.
******************************************
My doc is like this:
<rooms>
        <room><desc maxoc="12">text0</desc></room>
        <room><desc maxoc="5"/>text1</desc></room>
        <room><desc maxoc="6"/>text2</desc></room>
        <room><desc maxoc="9"/>text3</desc></room>
</rooms>
*****************************************
This is in my html_jx page:
 <jx:forEach select="#{rooms/room}"  varStatus="status">
                    
 <jx:macro name="tablerows">
      <jx:parameter name="maxoc"/>
      <jx:forEach begin="0" end="${maxoc}" step="1" varStatus="statoc">
            <tr>
            <td><script>${statoc.count}</script></td>
            <td><script>${statoc.count*24}</script></td>
            <td><script>${maxoc}</script></td>
            </tr> 
       </jx:forEach>
  </jx:macro>
                   
<table>
    <tbody>
       <tablerows maxoc="${description.getAttribute('maxoc')}"/>  
</tbody>
</table>

</forEach>
*************************************

So as you can see the jexl element I need is relative to each room,  can
someone help me retreive the /rooms/room/description/@maxoc for each
room ?? 

Thanks


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


Mime
View raw message