cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <je...@apache.org>
Subject Re: [RT] the quest for the perfect template language
Date Thu, 03 Apr 2003 06:52:46 GMT
On Wed, Apr 02, 2003 at 08:25:49PM +0200, Stefano Mazzocchi wrote:
<snip interesting stuff>

> IMHO, the template language which is closer to the optimum is XSLT but 
> only with one change:
...
> then we can have the following templatesheet:
> 
> namespace ("ns") {
>  "http://whatever"
> }
> 
> template ("/") {
>  <html>
>   <head>
>    <title>{list/@name}</title>
>   </head>
>   <body>
>    <form action="{flow::continuation/id}">
>     <table>
>      attribute ("width") {
>        if ({deli:screen-width}) {
> 	{deli:screen-width}
>        } else {
>         "100%"
>        }
>      }
>      apply-templates
>     </table>
>    </form>
>   </body>
>  </html>
> }
> 
> template ("item") {
>  <tr>
>   <td>
>    if ({ns:subitem}) {
>      if ({count(ns:subitem}) > 1) {
>        for-each ({ns:subitem}) {
>          <span style="color:green">{.}</span>
>        }
>      } else {
>        <span style="color:red">{.}</span>
>      }
>    } else if ({request::lang} == {@lang}
>            || {request:://cookie/lang} == {@lang}) {
>      {.}
>    } else {
>      "unknown language \"" {@lang} "\""
>    }
>   </td>
>  </tr>
> }


It sounds odd, but I think XQuery could be a good language for generating
XML in this way.  It's pretty close to what you've written here.

http://www.xml.com/lpt/a/2002/12/23/xquery.html

Pity about losing the declarative processing model.

There's also JSL ("Jelly Stylesheet Language" I presume), which does the
job pretty well in Maven.

--Jeff

> 
> Stefano.
> 

Mime
View raw message