[jdom-interest] XmlOutputter : escaping of \r in element text
jhunter at xquery.com
Tue Oct 26 09:30:26 PDT 2004
We covered this really recently on the list, so go back to the archives
if you're curious about background. Short summary is since XML parsers
are mandated to normalize incoming \r\n line endings to \n we know that
your \r was specifically requested and thus we try to preserve it on
output for you. If you want line endings as \r\n, then use \n as a
logical newline in your setText() call and set the XMLOutputter to use
\r\n when it outputs line endings.
Thomas Fischer wrote:
> I have a problem concerning the escaping of windows linefeeds in element
> texts in JDOM 1.0:
> Element element = new element("test");
> XMLOutputter outputter = new XMLOutputter();
> outputter.output(document, System.out);
> The outputter prints the following
> while I just want to have
> I do not see how I could achieve this within jdom. Using EscapeStrategy is
> of no use, because it is not involved on the \r character (see jdom
> sources, XmlOutputter.java, line 1455).
> In my opinion, this behaviour only makes sense for the special characters
> defined in the xml spec (<">'&), but not for additional entities,
> because e.g. the character \r is a perfectly valid character within
> a xml document (see the xml specification,
> http://www.w3.org/TR/1998/REC-xml-1998021, chapter 2.2).
> A solution which would be 'backward compatible' in most cases would be to
> change the jdom source such that a "default escape strategy" is used which
> escapes the \r and \n character, but which can be overridden.
> What do you think ?
> To control your jdom-interest membership:
More information about the jdom-interest