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/03/18 10:40:19 UTC

RE: [jelly] body as unescaped xml

I never got a conclusive answer to this problem I posted a few weeks ago.  A
proposed solution was to use the "encode" attribute of the <j:set/> tag, but
it doesn't have any effect for some reason.  So maybe it's a bug in Jelly?

To restate the problem: If I set a variable to some XML data and later
dereference this variable, the output is escaped using XML entities.  I
would like the output to be in unescaped form.  I have tried the following:

	<j:jelly xmlns:j="jelly:core">
	 <j:set var="foo" encode="false">
	  <bar/>
	 </j:set>
	 ${foo}
	</j:jelly>

but despite the "encode" attribute is set to false the output is
"&lt;bar&gt;&lt;/bar&gt;".  And I'd like it to be "<bar></bar>" (or
"<bar/>").

Cheers,

--
knut

> > > I noticed that <j:set/> has an "encode" attribute, but 
> > that's used to
> > encode
> > > stuff like "&lt;" into "&amp;lt;", right?  So you propose 
> > to add another
> > > attribute "encoding" to control whether to encode data into 
> > valid XML
> > text?
> > 
> > Sorry I meant the 'encode' attribute. This defaults to true 
> which will
> > encode > into &lt;. So setting this to false will fix your issue.
> > 
> 
> Doesn't seem to work for me (using CVS version)...  No matter if I set
> "encode" to true or false, the outcome of the script:
> 
> <j:jelly xmlns:j="jelly:core">
>  <j:set var="foo" encode="false">
>   <bar/>
>  </j:set>
>  ${foo}
> </j:jelly>
> 
> is always "&lt;bar&gt;&lt;/bar&gt;".  Am I missing something 
> else here?
> 

RE: [jelly] body as unescaped xml

Posted by di...@multitask.com.au.
It's definitely a problem.

<j:set var="xx">${expr}</j:set> escapes and <j:set var="xx" 
value="${expr}"/> doesn't 
;-(
--
dIon Gillard, Multitask Consulting
Blog:      http://www.freeroller.net/page/dion/Weblog
Work:      http://www.multitask.com.au


"Wannheden, Knut" <kn...@paranor.ch> wrote on 18/03/2003 08:40:19 
PM:

> I never got a conclusive answer to this problem I posted a few weeks 
ago.  A
> proposed solution was to use the "encode" attribute of the <j:set/> tag, 
but
> it doesn't have any effect for some reason.  So maybe it's a bug in 
Jelly?
> 
> To restate the problem: If I set a variable to some XML data and later
> dereference this variable, the output is escaped using XML entities.  I
> would like the output to be in unescaped form.  I have tried the 
following:
> 
>    <j:jelly xmlns:j="jelly:core">
>     <j:set var="foo" encode="false">
>      <bar/>
>     </j:set>
>     ${foo}
>    </j:jelly>
> 
> but despite the "encode" attribute is set to false the output is
> "&lt;bar&gt;&lt;/bar&gt;".  And I'd like it to be "<bar></bar>" (or
> "<bar/>").
> 
> Cheers,
> 
> --
> knut
> 
> > > > I noticed that <j:set/> has an "encode" attribute, but 
> > > that's used to
> > > encode
> > > > stuff like "&lt;" into "&amp;lt;", right?  So you propose 
> > > to add another
> > > > attribute "encoding" to control whether to encode data into 
> > > valid XML
> > > text?
> > > 
> > > Sorry I meant the 'encode' attribute. This defaults to true 
> > which will
> > > encode > into &lt;. So setting this to false will fix your issue.
> > > 
> > 
> > Doesn't seem to work for me (using CVS version)...  No matter if I set
> > "encode" to true or false, the outcome of the script:
> > 
> > <j:jelly xmlns:j="jelly:core">
> >  <j:set var="foo" encode="false">
> >   <bar/>
> >  </j:set>
> >  ${foo}
> > </j:jelly>
> > 
> > is always "&lt;bar&gt;&lt;/bar&gt;".  Am I missing something 
> > else here?
> >