cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Oliver <>
Subject Re: JXTemplateTransformer Questions
Date Thu, 08 May 2003 02:59:48 GMT
Stefano Mazzocchi wrote:

>First of all, the more I use JXTemplateTransformer, the more I think it
>should be replaced by intrumenting our TraxTransformer to be able to
>have access to the data coming from the flow layer... what do others
>think about this?
Try TraxGenerator in the scratchpad. It works by wrapping beans with DOM 
interfaces. The input "document" to the XSLT processor is a 
java.util.Map containing the properties of the bean object passed to 
sendPage(), the continuation, and the request, session, context, and 

Although it seems to work to some extent, this is not a very good 
approach, in my opinion, because it cannot handle object graphs that 
contain cycles (causes infinite recursion when calling DOM operations 
like "getFirstChild()").

My latest thinking is that it would be best to write our own STX 
processor that uses JXPath to handle XPath processing of Java objects 
passed as parameters. STX looks fairly easy to implement, and fits into 
Cocoon's pipeline framework much better than XSLT. What do you think?

>Second, is it possible to iterate over a java Collection directly with
Yes, of course.

>If not, what is the best/advisable way to do this without migrating the
>data to a javascript array?
>ah, also, if you have a javascript array, what do you use for #{item/?}?
Within <forEach> you can refer to the current item as #{.}

>[BTW, why t:forEach instead of reusing the xslt for-each name? I think
>we should avoid reinventing the wheel semantically as much as possible]
I didn't invent these names, they are taken directly from JSTL.

>last thing: if you fail to provide a meaningful #{item/?} value, the
>error returned is "no pointer for xpath" and the stacktrace comes out of
>Xalan!, which isn't meaningful at all! I spent half an hour
>understanding this was not a xalan bug but a problem with my own failing
>to provide the right item xpath.
Sorry, but it seems that error messages suck for all Cocoon transformers 
(no line numbers or file names). I don't know how to fix that. The only 
thing I can recommend is to run it as generator to do debugging.

>thanks for any answer you could provide

You're welcome.



View raw message