Stefano Mazzocchi wrote:
Christopher Oliver wrote:

Yesterday, I was trying to create another view for the flow layer, similar to a subset of JSTL, using Jexl

http://jakarta.apache.org/commons/jexl

I started with Marcus Crafter's JPathTransformer, and in the process of writing JexlTransformer, I also attempted to add support for for-each and choose/when/otherwise to JPathTransformer (both extend AbstractSAXTransformer).

Just one question: why transformers?

Good question. Ovidiu basically said the same thing. He pointed out that ideally XML processing of a Jexl/JXPath template should happen only once, to convert the page template to the final XML and later generate a Java class, similar to what JSP does. This should be much faster than the usage pattern of starting with a page template containing JXPath/Jexl instructions that will be evaluated at runtime to generate an XML document - which implementing the JXPath/Jexl template processor as a tranformer leads to.


I think Marcus starting implementing JPathTranformer because he didn't want to use Xsp: he was on MacOS and didn't want to depend on Javac. This shouldn't matter anymore now that the eclipse Java compiler is built into Cocoon.

As for me I was more interested in getting the user friendly behavior of the embedded expression language of Velocity and JSTL provides compared to the JPath Xsp logic sheet. Although it is an interpreted solution, implementing this behavior as a transformer seemed like the easiest way.

How is your profiling of Cocoon coming? It would be interesting to find out if a compiled versus interpreted template has a measurable difference in the overall performance of Cocoon.


Then I came across Volker Schmitt's taglib in the scratchpad which looks like exactly what I wanted:

http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=102227009022017&w=2

In my opinion, given the Cocoon flow layer and Cocoon's support for XSL, we don't don't need extensive tag libraries, but instead just the equivalent of a subset of JSTL core flow tags, and its expression language:

<if/>
<forEach/>
<choose/>
<out/>


aahhhhhhhhhhhhhhhhhhhhhhhhhhh!

the infamous <if/> anti-pattern: every markup language grows to include the <if/> element!

beware!


<if> and <choose> are needed to test for the presence of optional and/or alternative values in the bean object.


In other words, just enough to navigate through the contents of the "bean" object passed from the flow layer, in order to render output.


you have velocity and xsp that provide that functionality, why do you want another one in the transformation side? I don't understand.

You have a point. Maybe having too many template languages is a bad thing. But I was thinking that the JSTL expression language may become more well known than Velocity and unlike Velocity the Jexl template is XML. As for the Jpath logic sheet, as I mentioned above, it doesn't have an embedded expression language, so you have to use <xsp:attribute> which seems very unfriendly.



This is equivalent to the functionality Ovidiu included in the jpath Xsp logic sheet.

And this is the functionality that JexlTransformer and JXPathTransformer provide, with Jexl and JXPath as the expression languages, respectively.

I would like to reimplement JexlTransformer and JXPathTransformer using taglib (if anyone want's to help, let me know).

Assuming this works, I'd also like to reimplement XMLFormTransformer using taglib and move taglib to the core as a proper API for writing transformers in the future.


Please, provide a wider context as for what you are trying to achieve and what problems you are trying to solve because it's not clear at all.

I'm not being critic, just want to know the full context because I'm not able to do any costructive criticism without one.


I think what I'm trying to achieve is to flush out what the "view" layer API(s) to communicate with the flow layer should be.


Regards,

Chris




Reply via email to