"Jelly could have a surface syntax that looks similar to Velocity. i.e. someone could make a parser of Jelly that had a look-and-feel of Velocity for common directives and expressions."
Now, what do I mean by "simpler" sintax? Imagine, for example a "foreach" statement:
In XML (or better XSLT, but at the end of the day it'll have to apply to any possible template which is based on XML) it looks quite ugly, to my standards:
<ul> <xsl:foreach select="parameters"> <li><xsl:value-of select="@name"/>: <xsl:value-of select="@value"/></li> </xsl:foreach> </ul>
If you've ever used (and liked) velocity, for instance, you'd write something MUCH simpler, and in garbage (which is basically Velocity with Xpath), the same exact construct will become something like:
<ul> #foreach {parameters} <li>[EMAIL PROTECTED]: [EMAIL PROTECTED]</li> #end </ul>
Having only read one article about XQuery with a few samples this *looks* like XQuery for me. But my knowledge is not deep of course :-)
Sorry if I like the latter :-)
... complex xsl:choose sample snipped ...
<div> #if {parameter/@name = "primary"} <span class="red"> #elif {parameter/@name = "secondary"} <span class="green"> #elif {parameter/@name = "tertiary"} <span class="green"> #else <span> #end [EMAIL PROTECTED]:</span> [EMAIL PROTECTED] </div>
Hmm, in my opinion it should at least be impossible to produce not well-formed XML. With the above I'm not satisfied ...
Ok, ok, I could have written the above as:
<div> <span> <xsl:choose> <xsl:when test="parameter/@name = 'primary'"> <xsl:attribute name="class">red</xsl:attribute> </xsl:when> <xsl:when test="parameter/@name = 'secondary'"> <xsl:attribute name="class">green</xsl:attribute> </xsl:when> <xsl:when test="parameter/@name = 'tertiary'"> <xsl:attribute name="class">blue</xsl:attribute> </xsl:when> </xsl:choose> <xsl:value-of select="parameter/@name"/>: </span> <xsl:value-of select="parameter/@value"/> </div>
One step further:
<div> <span> <xsl:attribute name="class"> <xsl:choose> <xsl:when test="parameter/@name = 'primary'">red</xsl:when> <xsl:when test="parameter/@name = 'secondary'">green</xsl:when> <xsl:when test="parameter/@name = 'tertiary'">blue</xsl:when> </xsl:choose> </xsl:attribute> <xsl:value-of select="parameter/@name"/>: </span> <xsl:value-of select="parameter/@value"/> </div>
Ok, you will have an empty @class and the main point of your criticism remains of course ...
(which I don't know if it's easier, I just have to maybe set the class in a span depending on the name of a parameter)... But still, this is way too complicated for me (maybe not to write, but to read).
Also, the use of "<xsl:attribute ...>" will not allow us to start processing the "<span>" element until that is closed, as the "<xsl:attribute>" might be right at the end (and if that span contains something like 2 megs of data, well, you see where I'm going to...
Why? If any text or child element or ... is added no attribute can be added anymore.
And on, and on, and on...
Now, why Velocity ain't good for Cocoon IMVHO? It's stream based, and it's expression library is not something that will help me to introduce my graphic team to all the rest of the wonders of Cocoon.
Basically, yes, I reinvented the wheel... I took two of the different approaches used in the Cocoon PetStore for the view (JXPath and Velocity, which I liked better), added few bits of what Stefano said in his "[RT] the quest for the perfect template language", consulted XQuery, but Scott is a very bad driver and uses to many curly braces (and I go nuts), shakered, added salt and pepper, built and climbed a tree, parsed the garden with JavaCC, and puff... Here comes out the trash...
Ah, here you come to XQuery. Too many braces? It's at least much shorter than the complete XML syntax of XSLT.
Pier
Joerg
--
System Development VIRBUS AG Fon +49(0)341-979-7419 Fax +49(0)341-979-7409 [EMAIL PROTECTED] www.virbus.de