You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Karr, David" <Da...@wamu.net> on 2003/06/20 01:58:43 UTC

Best way to make XMLSerializer not encode single quotes

I've discovered the interesting issue with taking body content that
contains single quotes and serializing that into an XML document, which
is actually intended to be viewed as HTML.  The result is that it mucks
up (replaces with "&apos;") the single quotes when it is viewed in IE
(although not in Mozilla, interestingly).

I have code which is currently using the XMLSerializer class.  What is
the best way to resolve this issue?  I noticed the
"setNonEscapingElements()" method, but that's sort of brutal.  I still
want it to encode "<" characters, but not "'" characters.  Should I be
using a different serializer?


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Best way to make XMLSerializer not encode single quotes

Posted by David Nutter <Da...@durham.ac.uk>.
On Thu, Jun 19, 2003 at 04:58:43PM -0700, Karr, David wrote:
> I've discovered the interesting issue with taking body content that
> contains single quotes and serializing that into an XML document, which
> is actually intended to be viewed as HTML.  The result is that it mucks
> up (replaces with "&apos;") the single quotes when it is viewed in IE
> (although not in Mozilla, interestingly).

The reason is that IE does not appear to handle the XML entity &apos;
and merely prints it out instead of rendering it correctly as a "'"
like Mozilla does. I've seen this problem with some XHTML websites I
maintain; it's a real pain. 

Xerces and Mozilla's behaviour is correct, IE's is not, unfortunately :(

IIRC you can work around it by replacing &apos; with either &#x27; or
&#39; and retain valid XML but that leads you back to square one I
think. 

Sorry I can't be more helpful!

Regards,

-- 
David Nutter <da...@durham.ac.uk>	Research Assistant
Rm E326, Department Of Computer Science, 
University Of Durham, 
Durham, DH1 3LE			 Tel: +44(0)191 3341745

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org