You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Stefan <st...@telig.de> on 2007/02/14 16:21:23 UTC

ampersand (&) handling in jspx - any workaround?

Hello,

for sure, the problem is well known. jspx pages turn the "&amp;" in 
simple "&" which causes a lot of problems. See
http://www.lunatech-research.com/archives/2006/01/20/jsp-xml-rant
for details.

How to avoid this problems? Or just live with it?

Thanks

-- 
Stefan


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Stefan <st...@telig.de>.
Nicholas Sushkin schrieb:
> He doesn't want to see '&amp;', he wants to see '&' in his browser rendering 
> an XHTML document produced by an JSPX page. So, the point of the post was 
> probably that XHTML serializer of JSPX output should be more XML-like and 
> serialize '&' as '&amp;', not as '&'.
>
> On Wednesday 14 February 2007 12:38, Christopher Schultz wrote: 
>
>   
>> If you put &amp; into an XML file, it gets treated as a single '&'. If
>> you want '&amp;', you gotta say '&amp;amp;'. <shrug>
>>     
>
>   
Almost. I'll produce xml which goes through a xslt filter. The jspx 
should generate a valid xml file and it would be nice, if the users can 
produce the jspx files with standard editors/methods, without "double-amps".

-- 
Stefan


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Nicholas Sushkin <ns...@openfinance.com>.
He doesn't want to see '&amp;', he wants to see '&' in his browser rendering 
an XHTML document produced by an JSPX page. So, the point of the post was 
probably that XHTML serializer of JSPX output should be more XML-like and 
serialize '&' as '&amp;', not as '&'.

On Wednesday 14 February 2007 12:38, Christopher Schultz wrote: 

> If you put &amp; into an XML file, it gets treated as a single '&'. If
> you want '&amp;', you gotta say '&amp;amp;'. <shrug>

-- 
Nicholas Sushkin, Senior Software Engineer
Open Finance

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Leon,

Leon Rosenberg wrote:
> correct me if i wrong, but isn't &amp; forbidden in xml anyway?

Nope. It's one of the only entities defined in XML (&amp;, &lt;, &gt;,
and &quot;, I think).

I'm not sure why the OP thinks this is an error.

If you put &amp; into an XML file, it gets treated as a single '&'. If
you want '&amp;', you gotta say '&amp;amp;'. <shrug>

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF00j59CaO5/Lv0PARAmwvAJ4j2dGrv22QYDehbeDpTqcMsIT19gCgvi01
Sr5VgkSU8+pgR4f9++ki/e4=
=bPMk
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Robert Koberg <ro...@koberg.com>.
On Wed, 14 Feb 2007 12:24:43 -0500, Leon Rosenberg  
<ro...@googlemail.com> wrote:

> correct me if i wrong, but isn't &amp; forbidden in xml anyway?

you're wrong.

> Leon
>
> On 2/14/07, Stefan <st...@telig.de> wrote:
>> Hello,
>>
>> for sure, the problem is well known. jspx pages turn the "&amp;" in
>> simple "&" which causes a lot of problems. See
>> http://www.lunatech-research.com/archives/2006/01/20/jsp-xml-rant
>> for details.
>>
>> How to avoid this problems? Or just live with it?
>>
>> Thanks
>>
>> --
>> Stefan
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Stefan <st...@telig.de>.
David Smith schrieb:
> Ok... you are wrong.   An & by itself is wrong.
>
> It's a hack, but you end up having to do &amp;amp;
>
> Seems like these should be preserved instead of decoded when the 
> output is x/html. I can see it getting real ugly if you  have to 
> process a document through several transforms.   But that's just my 
> opinion.
>
> -David
>
> Leon Rosenberg wrote:
>> correct me if i wrong, but isn't &amp; forbidden in xml anyway?
>> Leon
>>
>> On 2/14/07, Stefan <st...@telig.de> wrote:
>>> Hello,
>>>
>>> for sure, the problem is well known. jspx pages turn the "&amp;" in
>>> simple "&" which causes a lot of problems. See
>>> http://www.lunatech-research.com/archives/2006/01/20/jsp-xml-rant
>>> for details.
>>>
>>> How to avoid this problems? Or just live with it?
>>>
>>> Thanks
>>>
>>> -- 
>>> Stefan
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
So to avoid the "double-amp" I have to write a filter, which transforms 
a single "&" in "&amp;" I'll try that but it is a strange behavior of 
servlet engines. Usually you use jspx to generate XHTML or XML, as I 
need to do.

Thanks for the participation
Stefan

-- 
Stefan


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Leon Rosenberg <ro...@googlemail.com>.
On 2/14/07, Stefan <st...@telig.de> wrote:
> Leon Rosenberg schrieb:
> > On 2/14/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
> >> ...
> >
> > &#uuuu;
> > the &amp; is not xml its html.
> > Btw, & isn't allowed in html as well, for example in links.
> >
> > regards
> > Leon
> >
> >>
> >> ...
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> Hi Leon,
>
> I don't understand what you mean exactly but:
>
> Not wellformed xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <nogood>&</nogood>
>
> Wellformed xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <good>&amp;</good>
>
> Kind regards
> Stefan
>

ok, than i'm wrong :-)
Leon

> --
> Stefan
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Stefan <st...@telig.de>.
Leon Rosenberg schrieb:
> On 2/14/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
>> ...
>
> &#uuuu;
> the &amp; is not xml its html.
> Btw, & isn't allowed in html as well, for example in links.
>
> regards
> Leon
>
>>
>> ...
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Hi Leon,

I don't understand what you mean exactly but:

Not wellformed xml:

<?xml version="1.0" encoding="UTF-8"?>
<nogood>&</nogood>

Wellformed xml:

<?xml version="1.0" encoding="UTF-8"?>
<good>&amp;</good>

Kind regards
Stefan

-- 
Stefan


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Leon Rosenberg <ro...@googlemail.com>.
On 2/14/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Leon,
>
> Leon Rosenberg wrote:
> > On 2/14/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
> >> If the &'s were preserved, then how would you actually emit an '&'
> >> character?
> >
> > &#uuuu;
> > the &amp; is not xml its html.
>
> It's both, actually.
>
> > Btw, & isn't allowed in html as well, for example in links.
>
> Untrue. HTML allows bare & symbols. XHTML forbids them (for example, in
> links).

Normal html forbids them too. at least according to
http://validator.w3.org/

regards
Leon

>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFF02vN9CaO5/Lv0PARAoCyAJ4gFNM4TLbChuHdVS9S862psxzuGgCdEwsD
> 33/7qrnPaIB5GW69cylsuS8=
> =+GDv
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Leon,

Leon Rosenberg wrote:
> On 2/14/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
>> If the &'s were preserved, then how would you actually emit an '&'
>> character?
> 
> &#uuuu;
> the &amp; is not xml its html.

It's both, actually.

> Btw, & isn't allowed in html as well, for example in links.

Untrue. HTML allows bare & symbols. XHTML forbids them (for example, in
links).

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF02vN9CaO5/Lv0PARAoCyAJ4gFNM4TLbChuHdVS9S862psxzuGgCdEwsD
33/7qrnPaIB5GW69cylsuS8=
=+GDv
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Leon Rosenberg <ro...@googlemail.com>.
On 2/14/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> David,
>
> David Smith wrote:
> > Seems like these should be preserved instead of decoded when the output
> > is x/html.
>
> If the &'s were preserved, then how would you actually emit an '&'
> character?

&#uuuu;
the &amp; is not xml its html.
Btw, & isn't allowed in html as well, for example in links.

regards
Leon

>
> I think that the OP and the author of the rant against JSPXs are both
> attempting to ignore the fact that a JSPX is not simple another XML
> document. It's an XML document that generates another XML document.
> Given that, special attention ought to be paid to XML entities such as
> these.
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFF02DO9CaO5/Lv0PARAr0WAJ4m+3gItG3DkUJNK/EwRvL9rjIt6ACfZHnD
> 86OlEMvUBT45QCq068PVLpo=
> =1uxt
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Stefan <st...@telig.de>.
Robert Koberg schrieb:
> On Wed, 14 Feb 2007 15:05:02 -0500, Christopher Schultz 
> <ch...@christopherschultz.net> wrote:
>
>> Stefan wrote:
>>> but where do I need a single "&" in the generated XML. That's forbidden
>>> a causes the problems. Can You come up a use case?
>>
>> Oh, I'm not saying that it's a good idea. I actually agree that emitting
>> a single & doesn't make any sense.
>>
>> Compare this to XSLT. If you want a stylesheet to emit an '&', don't you
>> use &amp;? And if you want to emit '&amp;' you have to double it.
>
> No, if your output method is XML (or XHTML in XSL v2) then it does not 
> convert it to &. If your output is HTML or text then it does.
>
> Why not just use XSL or something like Velocity or Freemarker?
Simplicity and flexibility.  We have a cocoon site running for about 3 
or 4 years. For the application we develop now, we do not need that much 
xml functionality. It gets not even heavy loaded. So a simple xslt 
filter servlet will do the trick and we are open to use all other 
frameworks as needed in the future. But anyway a good hint. I'll read 
about the mentioned frameworks. Thanks.
>
> best,
> -Rob
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Stefan


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Robert Koberg <ro...@koberg.com>.
On Wed, 14 Feb 2007 15:05:02 -0500, Christopher Schultz  
<ch...@christopherschultz.net> wrote:

> Stefan wrote:
>> but where do I need a single "&" in the generated XML. That's forbidden
>> a causes the problems. Can You come up a use case?
>
> Oh, I'm not saying that it's a good idea. I actually agree that emitting
> a single & doesn't make any sense.
>
> Compare this to XSLT. If you want a stylesheet to emit an '&', don't you
> use &amp;? And if you want to emit '&amp;' you have to double it.

No, if your output method is XML (or XHTML in XSL v2) then it does not  
convert it to &. If your output is HTML or text then it does.

Why not just use XSL or something like Velocity or Freemarker?

best,
-Rob


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Stefan <st...@telig.de>.
Pid schrieb:
> Stefan wrote:
>> Christopher Schultz schrieb:
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Stefan,
>>>
>>> Stefan wrote:
>>>  
>>>> Christopher Schultz schrieb:
>>>>   
>>>>> Compare this to XSLT. If you want a stylesheet to emit an '&', 
>>>>> don't you
>>>>> use &amp;? And if you want to emit '&amp;' you have to double it. I
>>>>> don't see the difference, and I think that the OP is being
>>>>> unreasonable ;)
>>>>>       
>>>>   Not in my xslt ;-) It depends of the output method. If you output 
>>>> xml,
>>>> &amp; still gets &amp; It is meanless to create a not well formed 
>>>> xml. I
>>>> don't remember what the output method text or html makes.
>>>>     
>>>
>>> Fair enough. When you put "&amp;" into your XSLT, the processor sees it
>>> as "entity:amp". When you write that out, the exact display depends on
>>> the output format. If it's emitting XML (or XHTML), you get "&amp;"
>>> right back out.
>>>
>>> But, if you're outputting HTML (?) or text (definitely), then you get
>>> '&'. If you want to emit "&amp;" in text mode, you'll definitely 
>>> have to
>>> double-up the amps.
>>>
>>> The problem is that JSPX is not XSLT. It's really JSP with some extra
>>> junk thrown in. Fortunately for me, I don't have to use it ;)
>>>   
>> Yes, I start to understand the ins and outs. Perhaps the spec writers 
>> just could not imagine, that someone will use jspx to do what  it is 
>> great for, to produce xml ;-) So I'll go for my filter and wait for 
>> future jsp specs which will include something like
>> <jsp:output preserve-xml-entities="true" /> or 
>> <jsp:output-method="xml" /> Similar directives for omitting XML 
>> declarations etc. are already included.
>
> i'll weigh in late with this thread...
>
> how then do i differentiate an ampersand that i need to process in the 
> source document?
>
>
>
> in general there are 2 use cases for ampersands in xml generating xml 
> docs:
>
> 1. xml source doc needs to process/contain an ampersand
> 2. xml generated doc needs to process/contain an ampersand
>
> the solution that the spec implements is double encoding in the source 
> document - and it makes complete sense if you consider the two cases 
> above; even if it doesn't make immediate, intuitive sense to an end 
> user who is moving from the JSP to JSP Document format and who is only 
> considering the 2nd case.
>
> the JSP document format has some strengths but also some practical 
> weaknesses which is probably why it's adoption hasn't been as 
> widespread...
>
>
> p
>
>
Hi again, haven't been on my desk yesterday.

I don't get it. It doesn't seem that complicated. We have a similar 
situation with xslt. A xml source document (the jspx document), a
xslt processor (the jsp servlet) and a result (the response). The result 
can be xml, html or text (binary data). Depending of the output method, 
the xslt processor preserves the "&amp;"s (xml output) or not (text 
output). Why not just include a directive <jsp:output-method="xml" /> 
and handle the amps accordingly?

Perhaps I did not get the point, but for me, it's just missing this 
directive.

Regards

-- 
Stefan


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by David Smith <dn...@cornell.edu>.
Pid wrote:

> Stefan wrote:
>
>> Christopher Schultz schrieb:
>>

> Stefan,
>
> Stefan wrote:
>  
>
> >>>> Christopher Schultz schrieb:
> >>>>   
> >>>>
> >>>>> Compare this to XSLT. If you want a stylesheet to emit an '&',
> don't you
> >>>>> use &amp;? And if you want to emit '&amp;' you have to double it. I
> >>>>> don't see the difference, and I think that the OP is being
> >>>>> unreasonable ;)
> >>>>>       
> >>>>
> >>>>   Not in my xslt ;-) It depends of the output method. If you
> output xml,
> >>>> &amp; still gets &amp; It is meanless to create a not well formed
> xml. I
> >>>> don't remember what the output method text or html makes.
> >>>>     
>
>
> Fair enough. When you put "&amp;" into your XSLT, the processor sees it
> as "entity:amp". When you write that out, the exact display depends on
> the output format. If it's emitting XML (or XHTML), you get "&amp;"
> right back out.
>
> But, if you're outputting HTML (?) or text (definitely), then you get
> '&'. If you want to emit "&amp;" in text mode, you'll definitely have to
> double-up the amps.
>
> The problem is that JSPX is not XSLT. It's really JSP with some extra
> junk thrown in. Fortunately for me, I don't have to use it ;)
>  
> >>
> >> Yes, I start to understand the ins and outs. Perhaps the spec
> writers just could not imagine, that someone will use jspx to do what 
> it is great for, to produce xml ;-) So I'll go for my filter and wait
> for future jsp specs which will include something like
> >> <jsp:output preserve-xml-entities="true" /> or
> <jsp:output-method="xml" /> Similar directives for omitting XML
> declarations etc. are already included.
>
>
> > i'll weigh in late with this thread...
>
> > how then do i differentiate an ampersand that i need to process in
> the source document?
>
>
>
> > in general there are 2 use cases for ampersands in xml generating
> xml docs:
>
> > 1. xml source doc needs to process/contain an ampersand
> > 2. xml generated doc needs to process/contain an ampersand
>
> > the solution that the spec implements is double encoding in the
> source document - and it makes complete sense if you consider the two
> cases above; even if it doesn't make immediate, intuitive sense to an
> end user who is moving from the JSP to JSP Document format and who is
> only considering the 2nd case.
>
> > the JSP document format has some strengths but also some practical
> weaknesses which is probably why it's adoption hasn't been as
> widespread...
>
>
> > p
>
>
>
> -chris


I'm sorry I missed most of this debate yesterday :-(  Admittedly this
can be a prickly issue from the jsp compiler stand point in trying to
know when an & is just a & and when it's an entity for output to a
(x)html or xml response.  I have two thoughts that are probably better
served on the tomcat-dev list or as comments to the spec committee:

1. Xml spec allows for material to be escaped in the source with
<![CDATA[ ..... ]]>.  I've done this with jspx files that have included
jsp:scriptlet sections.  It's easier than trying to make sure all the
special characters in the java scriptlet source are properly referenced.

2. It would be nice if the compiled resulting servlet paid attention to
the type of the response and handled entity references properly on
output.  Text/binary/misc types get a dereferenced entity while (x)html
and xml output leaves the entity intact as stated in the source jspx.

I appreciate the problem as the output doesn't necessarily have to be
just (x)html or xml.  Sometimes the output is straight text or a binary
format of some sort.  Maybe the end solution is an attribute of the jsp
tag that defines the response type.  That would maintain backwards
compatibility with existing jspx sources.

--David

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Pid <p...@pidster.com>.
Stefan wrote:
> Christopher Schultz schrieb:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Stefan,
>>
>> Stefan wrote:
>>  
>>> Christopher Schultz schrieb:
>>>    
>>>> Compare this to XSLT. If you want a stylesheet to emit an '&', don't 
>>>> you
>>>> use &amp;? And if you want to emit '&amp;' you have to double it. I
>>>> don't see the difference, and I think that the OP is being
>>>> unreasonable ;)
>>>>       
>>>   Not in my xslt ;-) It depends of the output method. If you output xml,
>>> &amp; still gets &amp; It is meanless to create a not well formed xml. I
>>> don't remember what the output method text or html makes.
>>>     
>>
>> Fair enough. When you put "&amp;" into your XSLT, the processor sees it
>> as "entity:amp". When you write that out, the exact display depends on
>> the output format. If it's emitting XML (or XHTML), you get "&amp;"
>> right back out.
>>
>> But, if you're outputting HTML (?) or text (definitely), then you get
>> '&'. If you want to emit "&amp;" in text mode, you'll definitely have to
>> double-up the amps.
>>
>> The problem is that JSPX is not XSLT. It's really JSP with some extra
>> junk thrown in. Fortunately for me, I don't have to use it ;)
>>   
> Yes, I start to understand the ins and outs. Perhaps the spec writers 
> just could not imagine, that someone will use jspx to do what  it is 
> great for, to produce xml ;-) So I'll go for my filter and wait for 
> future jsp specs which will include something like
> <jsp:output preserve-xml-entities="true" /> or <jsp:output-method="xml" 
> /> Similar directives for omitting XML declarations etc. are already 
> included.

i'll weigh in late with this thread...

how then do i differentiate an ampersand that i need to process in the 
source document?



in general there are 2 use cases for ampersands in xml generating xml docs:

1. xml source doc needs to process/contain an ampersand
2. xml generated doc needs to process/contain an ampersand

the solution that the spec implements is double encoding in the source 
document - and it makes complete sense if you consider the two cases 
above; even if it doesn't make immediate, intuitive sense to an end user 
who is moving from the JSP to JSP Document format and who is only 
considering the 2nd case.

the JSP document format has some strengths but also some practical 
weaknesses which is probably why it's adoption hasn't been as widespread...


p



>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.6 (MingW32)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iD8DBQFF03Ku9CaO5/Lv0PARAnGiAJ4moNhXPrF8DO6ujsDLicran2b5+QCfXYLx
>> CHxMCqxWfgOjcE/I0KA8Iik=
>> =dxKm
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>   
> 
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Stefan <st...@telig.de>.
Christopher Schultz schrieb:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Stefan,
>
> Stefan wrote:
>   
>> Christopher Schultz schrieb:
>>     
>>> Compare this to XSLT. If you want a stylesheet to emit an '&', don't you
>>> use &amp;? And if you want to emit '&amp;' you have to double it. I
>>> don't see the difference, and I think that the OP is being
>>> unreasonable ;)
>>>       
>>   
>> Not in my xslt ;-) It depends of the output method. If you output xml,
>> &amp; still gets &amp; It is meanless to create a not well formed xml. I
>> don't remember what the output method text or html makes.
>>     
>
> Fair enough. When you put "&amp;" into your XSLT, the processor sees it
> as "entity:amp". When you write that out, the exact display depends on
> the output format. If it's emitting XML (or XHTML), you get "&amp;"
> right back out.
>
> But, if you're outputting HTML (?) or text (definitely), then you get
> '&'. If you want to emit "&amp;" in text mode, you'll definitely have to
> double-up the amps.
>
> The problem is that JSPX is not XSLT. It's really JSP with some extra
> junk thrown in. Fortunately for me, I don't have to use it ;)
>   
Yes, I start to understand the ins and outs. Perhaps the spec writers 
just could not imagine, that someone will use jspx to do what  it is 
great for, to produce xml ;-) So I'll go for my filter and wait for 
future jsp specs which will include something like
<jsp:output preserve-xml-entities="true" /> or <jsp:output-method="xml" 
/> Similar directives for omitting XML declarations etc. are already 
included.

> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFF03Ku9CaO5/Lv0PARAnGiAJ4moNhXPrF8DO6ujsDLicran2b5+QCfXYLx
> CHxMCqxWfgOjcE/I0KA8Iik=
> =dxKm
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>   


-- 
Stefan


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stefan,

Stefan wrote:
> Christopher Schultz schrieb:
>> Compare this to XSLT. If you want a stylesheet to emit an '&', don't you
>> use &amp;? And if you want to emit '&amp;' you have to double it. I
>> don't see the difference, and I think that the OP is being
>> unreasonable ;)
>   
> Not in my xslt ;-) It depends of the output method. If you output xml,
> &amp; still gets &amp; It is meanless to create a not well formed xml. I
> don't remember what the output method text or html makes.

Fair enough. When you put "&amp;" into your XSLT, the processor sees it
as "entity:amp". When you write that out, the exact display depends on
the output format. If it's emitting XML (or XHTML), you get "&amp;"
right back out.

But, if you're outputting HTML (?) or text (definitely), then you get
'&'. If you want to emit "&amp;" in text mode, you'll definitely have to
double-up the amps.

The problem is that JSPX is not XSLT. It's really JSP with some extra
junk thrown in. Fortunately for me, I don't have to use it ;)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF03Ku9CaO5/Lv0PARAnGiAJ4moNhXPrF8DO6ujsDLicran2b5+QCfXYLx
CHxMCqxWfgOjcE/I0KA8Iik=
=dxKm
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Stefan <st...@telig.de>.
Christopher Schultz schrieb:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Stefan,
>
> Stefan wrote:
>   
>> but where do I need a single "&" in the generated XML. That's forbidden
>> a causes the problems. Can You come up a use case?
>>     
>
> Oh, I'm not saying that it's a good idea. I actually agree that emitting
> a single & doesn't make any sense.
>
> Compare this to XSLT. If you want a stylesheet to emit an '&', don't you
> use &amp;? And if you want to emit '&amp;' you have to double it. I
> don't see the difference, and I think that the OP is being unreasonable ;)
>   
Not in my xslt ;-) It depends of the output method. If you output xml, 
&amp; still gets &amp; It is meanless to create a not well formed xml. I 
don't remember what the output method text or html makes.

> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFF02tu9CaO5/Lv0PARAjkbAJ9RSY47qhNVLRtIFgng41ZTrHeNIwCeIPRI
> 4MFEoiwKykHGmHUo+a5N1oA=
> =B/gg
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>   


-- 
Stefan


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stefan,

Stefan wrote:
> but where do I need a single "&" in the generated XML. That's forbidden
> a causes the problems. Can You come up a use case?

Oh, I'm not saying that it's a good idea. I actually agree that emitting
a single & doesn't make any sense.

Compare this to XSLT. If you want a stylesheet to emit an '&', don't you
use &amp;? And if you want to emit '&amp;' you have to double it. I
don't see the difference, and I think that the OP is being unreasonable ;)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF02tu9CaO5/Lv0PARAjkbAJ9RSY47qhNVLRtIFgng41ZTrHeNIwCeIPRI
4MFEoiwKykHGmHUo+a5N1oA=
=B/gg
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Stefan <st...@telig.de>.
Christopher Schultz schrieb:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> David,
>
> David Smith wrote:
>   
>> Seems like these should be preserved instead of decoded when the output
>> is x/html.
>>     
>
> If the &'s were preserved, then how would you actually emit an '&'
> character?
>
> I think that the OP and the author of the rant against JSPXs are both
> attempting to ignore the fact that a JSPX is not simple another XML
> document. It's an XML document that generates another XML document.
> Given that, special attention ought to be paid to XML entities such as
> these.
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFF02DO9CaO5/Lv0PARAr0WAJ4m+3gItG3DkUJNK/EwRvL9rjIt6ACfZHnD
> 86OlEMvUBT45QCq068PVLpo=
> =1uxt
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>   
Hi Chris,
but where do I need a single "&" in the generated XML. That's forbidden 
a causes the problems. Can You come up a use case?

-- 
Stefan


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David,

David Smith wrote:
> Seems like these should be preserved instead of decoded when the output
> is x/html.

If the &'s were preserved, then how would you actually emit an '&'
character?

I think that the OP and the author of the rant against JSPXs are both
attempting to ignore the fact that a JSPX is not simple another XML
document. It's an XML document that generates another XML document.
Given that, special attention ought to be paid to XML entities such as
these.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF02DO9CaO5/Lv0PARAr0WAJ4m+3gItG3DkUJNK/EwRvL9rjIt6ACfZHnD
86OlEMvUBT45QCq068PVLpo=
=1uxt
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by David Smith <dn...@cornell.edu>.
Ok... you are wrong.   An & by itself is wrong.

 It's a hack, but you end up having to do &amp;amp;

Seems like these should be preserved instead of decoded when the output 
is x/html. I can see it getting real ugly if you  have to process a 
document through several transforms.   But that's just my opinion.

 -David

Leon Rosenberg wrote:
> correct me if i wrong, but isn't &amp; forbidden in xml anyway?
> Leon
>
> On 2/14/07, Stefan <st...@telig.de> wrote:
>> Hello,
>>
>> for sure, the problem is well known. jspx pages turn the "&amp;" in
>> simple "&" which causes a lot of problems. See
>> http://www.lunatech-research.com/archives/2006/01/20/jsp-xml-rant
>> for details.
>>
>> How to avoid this problems? Or just live with it?
>>
>> Thanks
>>
>> -- 
>> Stefan
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Markus Schönhaber <ma...@schoenhaber.de>.
Leon Rosenberg wrote:

> correct me if i wrong, but isn't &amp; forbidden in xml anyway?
> Leon

You're wrong. &amp; isn't forbidden in XML. In fact, it's one of the five 
predefined entities in XML.

Regards
  mks

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ampersand (&) handling in jspx - any workaround?

Posted by Leon Rosenberg <ro...@googlemail.com>.
correct me if i wrong, but isn't &amp; forbidden in xml anyway?
Leon

On 2/14/07, Stefan <st...@telig.de> wrote:
> Hello,
>
> for sure, the problem is well known. jspx pages turn the "&amp;" in
> simple "&" which causes a lot of problems. See
> http://www.lunatech-research.com/archives/2006/01/20/jsp-xml-rant
> for details.
>
> How to avoid this problems? Or just live with it?
>
> Thanks
>
> --
> Stefan
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org