[jdom-interest] Re: XmlOutputter : escaping of \r in element text

Thomas Fischer Fischer at seitenbau.net
Wed Oct 27 03:19:22 PDT 2004





I am not sure whether I understood your mail correctly. In JDOM, one can
also set the desired line separator in the outputter,
so I can specify that a \n in a text content becomes a \n, or a \r\n, or
perhaps even something else in the output.
But this applies only to the \n characters in text content, not to the \r
characters in element text.
If the JDOM Document originates from a XML parser, this is not an issue as
there are no \r characters present,
but if the text content is generated by hand, there might be extra "\r" (I
have never worked with XOM, but I guess the XOM analogue would be
element.appendChild("test\r\ntest"))
So the question which I want to pose is, what should happen to the \r
characters if one converts the document to a String, and I would suggest
the behaviour should be configurable, as the mechanisms to do this already
exist within JDOM (see class EscapeStrategy).

  Thomas

Elliotte Harold <elharo at metalab.unc.edu> schrieb am 27.10.2004 11:37:59:

> XOM takes a slightly different approach to this problem. By default it
> preserves everything like JDOM does. However, if you tell it you want a
> specific line break by calling setLineSeparator(), then it will change
> all line separators in the input data to the one you specify.
>
> --
> Elliotte Rusty Harold  elharo at metalab.unc.edu
> XML in a Nutshell 3rd Edition Just Published!
> http://www.cafeconleche.org/books/xian3/
> http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim



More information about the jdom-interest mailing list