FW: [jdom-interest] Outputting escaped entities in element text

Robert (Jamie) Munro rjmunro at arjam.net
Thu Oct 3 09:00:43 PDT 2002

> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of Elliotte Rusty Harold
> Sent: 03 October 2002 14:24
> To: David Moles; jdom-interest at jdom.org
> Subject: Re: [jdom-interest] Outputting escaped entities in element text
> What you need to do is this:
>   Element foo = new Element("inline", namespace);
>   foo.setText("\u2014;");
> >then in my XML I get
> >
> >   <fo:inline>[Unicode character 2014]</fo:inline>
> That's what you should get.
> >-- the character's not escaped, it's just encoded in UTF-8, as
> >you'd expect it to be. But then FOP doesn't know it needs to be
> >remapped, it looks for the character in the font it's using and
> >doesn't find it, and so in my PDF I get the "#" for "garbage
> >character".
> If this is true, and I still doubt it, then FOP is broken and needs
> to be fixed. This is not a JDOM problem.

Isn't the fix to use setEncoding("US-ASCII") and that way, it will come out
as &#2014;, or am I missing something?

It seems that half of the questions on this list are "I want my character to
appear as &#number; but it comes out as "x". How do I mess up my document so
this doesn't happen?" when the question should be "How do I make
XMLOutputter output it the way I want?", and the answer should be
setEncoding("[something]") or similar. Perhaps a way to define a custom
encoding for XMLOutputter to use, so that people who liked their "$" to
appear as &#0036; or even their "A"s to appear as &#0065; could have their
wishes granted.

Robert Munro

More information about the jdom-interest mailing list