Leon Messerschmidt wrote:
>
> Hi,
>
> I have a bit of a problem that I think is relevant to Anakia (and any other
> XML project) as well.
>
> I use Velocity extensively with XML and the single biggest problem is to
> replace XML entities for values inserted into a template. I have added a
> utility class to the context to assist in this but adding a call to this
> utility for each and every string didn't really seem like the right way of
> doing things.
>
> I then changed ASTReference to replace XML entities whenever something is
> inserted. This works better than the in-template solution, but it has some
> problems. The biggest drawback is that I cannot switch of entity
> replacement when I don't need it. I cannot use a property, because I have
> both XML and non-XML templates in one project. Also is only answers to the
> XML problem and not any other potential escaping/replacing problems.
>
> Are there any ideas how the right way of replacing XML entities inside
> Velocity would be? I'm currently thinking of adding an InsertionListener to
> the Context. Whenever you need to do processing you can supply an
> InsertionListener. It is notified whenever Velcity is about to insert a
> value in the template (ASTReference) and is then given the opportunity to do
> some processing for this value (like replacing XML entities).
>
> Are there any thoughts or comments on this? Jason, I believe you initially
> had an idea (Injectors if I remember correctly) that would have made this
> possible, but I don't really understand how that would've worked. Maybe you
> can shed some light...
I think the idea was 'filters' rather than Injectors.
What about a filtering mechanism on the stream you are rendering into?
geir
--
Geir Magnusson Jr. [EMAIL PROTECTED]
Developing for the web? See http://jakarta.apache.org/velocity/