[stringtemplate-interest] Escaping
Terence Parr
parrt at cs.usfca.edu
Tue May 3 09:08:54 PDT 2005
On May 1, 2005, at 4:49 PM, Tom Bentley wrote:
> Hi All,
>
> I have a question about escaping:
>
> On the one hand, I have a domain model which knows nothing about XML.
> Various classes have getters which could return an arbitrary String,
> including characters such as '&', '<', and '>' (i.e. not XML encoded
> as & < and >).
>
> On the other hand I have a StringTemplate instance that tries to
> produces some XML output based on the domain model. StringTemplate
> doesn't know about XML either.
>
> So my question is: How can I ensure that characters such as '&', '<',
> and '>' are correctly encoded in the XML output.
I'm partial to the idea of renderers now. Your controller wraps
objects such as name in other objects that render it according to the
target. I'm thinking of adding a mapping that lets you just once say
"wrap all String objects in HTMLStringRenderer objects".
Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
More information about the stringtemplate-interest
mailing list