cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Fagerstrom <dani...@nada.kth.se>
Subject Re: New expressions' syntax
Date Sat, 18 Aug 2007 15:02:40 GMT
Grzegorz Kossakowski skrev:
...

> I want 
> to:
>   a) allow people migrate to new expressions both in Template and 
> Sitemap smoothly
>   b) stay 100% back-compatible with old code behaviour while 
> implementing new ways of expression evaluation and most importantly 
> Object Model construction
>   c) avoid confusion about what's new and what's old
> 
> This leads us to small but very important question: how we wrap new 
> expressions? If I'm not wrong, current preference  has been to wrap new 
> expressions in {}, Daniel confirms[1] this view.
> 
> My own opinion is that plain {} are ok in sitemap but will not work well 
> in general. If choose {} as wrapping characters everything put between 
> this characters will be considered as expression. If you additionally 
> remember that all strings inside elements are treated as String 
> templates you may start to be warned. Take a look this[2] file's snippet:
> 
>   <style type="text/css">
>     #files { border-collapse: collapse; border-left: dotted black 1px; }
>     #files td { padding: 0.1em; border-bottom: dotted black 1px; }
>     .selected { background: #D0D0D0; }
>   </style>
> 
> It's a content of jx template but obviously we don't want 
> generator/transformer to interpret this CSS declarations as Cocoon 
> expressions! We would need to escape {} wrapping characters:
> 
>   <style type="text/css">
>     #files \{ border-collapse: collapse; border-left: dotted black 1px; \}
>     #files td \{ padding: 0.1em; border-bottom: dotted black 1px; \}
>     .selected \{ background: #D0D0D0; \}
>   </style>
> 
> It's ugly, don't you think?

The DefaultStringTemplateParser is actually implementing the escaping 
mechanism from atribute value templates in XSLT 
(http://www.w3.org/TR/xslt#dt-attribute-value-template. So the example 
rather becomes:

   <style type="text/css">
     #files {{ border-collapse: collapse; border-left: dotted black 1px; }}
     #files td {{ padding: 0.1em; border-bottom: dotted black 1px; }}
     .selected {{ background: #D0D0D0; }}
   </style>

Which IMO is a little bit less ugly than the "\{", "\}" escaping 
mechanism. And furthermore you should have most of your CSS in own files 
that you include, shouldn't you.

Looking at the parsing code I get the impression that "}}" -> "}" isn't 
implemented correctly.

> Next choice could be to use ${}. The problem with this characters is 
> that they are already used in Template and if we don't pick Jexl 
> language as default it will break current templates not to mention 
> confusion it would cause. We could come up with %{}, !{} or whatever is 
> not used yet. Everyone's keyboard has lot of remaining symbols waiting 
> for use but I wonder if we really want/need new wrappers.

I woulf be OK, with chosing Jexl as default EL and using "${}", but I 
prefer "{}".

/Daniel

> I'm stuck. Thoughts?
> 
> [1] http://marc.info/?l=xml-cocoon-dev&m=118703810504930&w=2
> [2] 
> http://svn.apache.org/repos/asf/cocoon/trunk/blocks/cocoon-forms/cocoon-forms-sample/src/main/resources/COB-INF/forms/file_explorer_template.xml

> 
> 



Mime
View raw message