[jdom-interest] character entity resolution?

cocoonlist78 cocoonlist78 at hotmail.com
Mon Apr 29 12:16:18 PDT 2002

  thanks for the information.  I've ended just parsing the text myself in
the servlet with a method that checks for inline elements.  I agree that it
is generally a bad idea to mix text and xml.  However, what do you recommend
for inline formatting (bold, italic, etc.)?  These inline elements have
worked pretty well in generating HTML and PDF so far.  Luckily JDOM supports
them with the setContent() method and text nodes mixed with elements
(instead of using setText()).  Is there a more elegant solution?


----- Original Message -----
From: "Jason Hunter" <jhunter at apache.org>
To: "cocoonlist78" <cocoonlist78 at hotmail.com>
Cc: "JDOM mailing list" <jdom-interest at jdom.org>
Sent: Saturday, April 27, 2002 12:12 PM
Subject: Re: [jdom-interest] character entity resolution?

> If you call elt.setText("<xml> content"); then on output it will write
> "&lt;xml&gr; content" because that's what you passed in and it needs to
> escape special characters to keep the same semantic meaning.
> JDOM doesn't do any magical attempt to parse the content you provide as
> XML.  Imagine the slowness!
> Some people have hacked the outputter to disable encoding, and you could
> do that, but it's a very bad idea to try to save XML or HTML as text and
> output it raw.  You're mixing two metaphors, and it'll bite you at some
> point.
> -jh-
> > cocoonlist78 wrote:
> >
> > JDOM users:
> >   I'm not sure if this is related to JDOM or not but maybe someone has
> > an idea:
> >
> >   I'm creating a web interface for editing XML documents.  The form
> > submits to a servlet that reads the existing XML document in and
> > represents it with JDOM.  I use setText() on the various Elements
> > to make changes based on the form data and then write out the new XML
> > file with XMLOutputter.output().  Some of the form fields contain XML
> > tags (for inline stuff like <italic> and <bold>).  Somewhere in the
> > process those inline XML tags that are coming across the CGI are being
> > changed from <italic> to &lt;italic&gt;.  This of course causes
> > problems because when the XML file is parsed these tags are seen as
> > strings rather than nodes.
> >
> > I've used System.out to check the strings and I don't see any entity
> > references as far as the servlet is concerned.  Maybe System.out
> > resolves them...
> >
> > Is there anything in the XMLOutputter.output()  or Element.setText()
> > methods that resolves these characters to HTML entities?  Any ideas?
> > Suggestions?
> >
> > Thanks

More information about the jdom-interest mailing list