You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Wannheden, Knut" <kn...@paranor.ch> on 2003/02/26 16:12:43 UTC

[jelly] body as unescaped xml

Hi,

I was surprised when I noticed that the following two scipts snippets don't
produce the same result:

	<foo/>

and:

	<j:set var="bar">
	 <foo/>
	</j:set>
	${bar}

The first one produces something like "<foo></foo>" whereas the second
produces something like "&lt;foo&gt;&lt;/foo&gt;".  I'm sure there's a good
reason for this I can't seem to think of... can someone explain it to me?
Also, is there another way to achieve what I'm trying to do?

TIA,

--
knut

Re: [jelly] body as unescaped xml

Posted by James Strachan <ja...@yahoo.co.uk>.
 From: "Wannheden, Knut" <kn...@paranor.ch>
> Hi,
>
> I was surprised when I noticed that the following two scipts snippets
don't
> produce the same result:
>
> <foo/>
>
> and:
>
> <j:set var="bar">
> <foo/>
> </j:set>
> ${bar}
>
> The first one produces something like "<foo></foo>" whereas the second
> produces something like "&lt;foo&gt;&lt;/foo&gt;".  I'm sure there's a
good
> reason for this I can't seem to think of... can someone explain it to me?
> Also, is there another way to achieve what I'm trying to do?

This is kinda non intuitive. I think we should probably fix it.

Basically when XML is output as text it can be encoded into a valid XML
string or left as is. So tags like <j:set> allow XML encoding to be turned
on or off.

    <j:set var="bar" encoding="false">
        <foo/>
    <j:set>

For some reason the default is to encode as XML text (I can't remember why
this is so). This is probably not a good thing; encoding should probably be
disabled by default. For now you can just specify the default encoding
true/false.

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com