> But what if I want to insert :
>
> <parent>
> $xmlblob
> </parent>
>
> where
>
> $xmlblob is "<child>William</child>"
>
> Then the listener approach screws things up too, right?
If you are going to insert an raw xml blob then you would probably be able
to assume that the blob of XML will be valid xml as generated by the xml
source. Otherwise it can't be called an XML blob - just some text with
random tags that looks like XML. You don't need to set the listener for
these.
> Now,
>
> <text>#escape("<>")</text>
>
> is disliked for some reason. Don't understand why yet.
1. I have template designers that will forget to call #escape(). I am
willing to bet money on that. The showstopper is that with 99% of the cases
it'll work not to call #escape. Only when somebody actually enters an
entity will the bug show up. It is very hard to track forgotten #escape's.
2. Because the XML parser stops with an exception it is not an issue of
just an artefact on the screen. A customer will see an error screen even a
possible java stack trace just because he entered a string containing an
entity.
3. It makes your template very ugly to call #escape for EACH insert. You
also need to have the #escape macro littering all your templates. I'd like
to keep tempaltes as simple as possible.
> What about
>
> #macro( node $tag $attr $text)
> #if ($text.length() > 0)
> <$tag $attr />
> #else
> <$tag $attr>#escape($text)</$tag>
> #end
> #end
>
> so
>
> #node( "text" "" "<>")
>
> Not as readable, I guess, but does guarantee closed nodes, I guess :)
Isn't this defying the purpose of a template in the first place :-) It is
starting to look a bit like ECS :-)
> Just thinking out loud here.
Don't get me wrong. I really appreciate your time.
~ Leon