You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jonas Ekstedt <ek...@ibg.uu.se> on 2004/11/08 05:35:59 UTC

Converting expression evaluator

Hello

I have created a small expression evaluator based on commons-el and
wondered if you would be interested in it. It is not finished but the
basic functionality is there.

The major feature of it is that it supports object conversion similar to
what Daniel Fagerström proposed some time ago:
http://www.mail-archive.com/dev@cocoon.apache.org/msg23888.html

Objects retrieved will be converted to the requested object type. One
can also supply a special type attribute that differentiates between
converters of similar sort. For example with a configuration file like
this:
--------------------------
<?xml version="1.0"?>
 
<root>
  <converter from="java.util.Date" to="java.lang.String"
class="conversion.DefaultDateStringConverter"/>

  <converter from="java.util.Date" to="java.lang.String" type="full"
class="conversion.DefaultDateStringConverter"/>
</root>
---------------------------

You can execute expressions like (if I have a date variable containing a
Date, and locale=sv):

${date} -> "2004-nov-08"
${date#full} -> "den 8 november 2004"

If you want to try it out it can be found at 
http://home.student.uu.se/j/joek8725/el.zip

Installation instructions:
* Unzip
* apply TagTransformer.patch in $COCOON_HOME
* cd el
* ant build.webapp
* ant test
* ant deploy
* point your servlet container to /path/to/el/webapp

To make it usable in a webapp I created an extended version of the
TagTransformer to support the expression evaluator. Currently
expressions can only be used in text nodes as I haven't gotten around to
doing it for attributes.

Cheers Jonas