I've been trying to find a way to do the following within an Anakia
style.vsl template:

   #set ($elem = $elem.addContent( new org.jdom.CDATA(" ") ))

The problem is that JDOM uses polymorphism on addContent in order to decide
whether to encode the new content (if it is a String) or not encode it
(if it is a CDATA class object), but Velocity doesn't have a way to define
variables other than String, Integer and Array (at least none that I have
found).

I can think of a couple solutions:

  a. (specific) Extend the JDOM Element type within Anakia to remove the
     polymorphism, so that I can do:

         #set ($elem = $elem.addContentCDATA(" "))

  b. (general)  Extend Velocity so that it can define new object types:

         #new ($nbsp = $org.jdom.CDATA(" "))
         #set ($elem = $elem.addContent($nbsp))

The first is easier to do, certainly, but I don't think Velocity can claim
to interoperate well with Java until it can do the second.

....Roy

Reply via email to