[jdom-interest] jdom 1.0 XMLOutputter

Bradley S. Huffman hip at cs.okstate.edu
Wed Sep 22 07:02:03 PDT 2004


Bill Leng writes:
> 
> Thanks for your help but I still have some questions. Let me try to explain.
>
> 1. the section 2.11 seems to be a requirement on xml processor to read 
> input. when I use XMLOutputter to serialize a jdom, does this rule apply?

Yes and no, the spec. covers what the parser should do, must do, or can do,
but not what object models like JDOM, XOM, DOM do.  But if a model is going to 
faithfully represent a document then you would assume that if you serialize
the model, then re-parse it you'd get back the same representation.

> 2. even this rule apply, what about a single \n? it still gets 
> translated to &#0A;
> 3. per XML spec, when "<root>\n</root>" gets parsed, \n does not need to 
> be translated to &#0A;. Is this correct?

In element content it get translated to the current line seperator, which
by default is "\r\n" and can be set in Format.

> 4. how do you retrieve the text that contains \n unchanged?

Set the line seperator in Format to "\n".

Brad


More information about the jdom-interest mailing list