[jdom-interest] Incorrect output

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Jun 28 17:59:42 PDT 2000


At 6:31 PM -0400 6/28/00, Thomas M. Sasala wrote:
>	I am parsing the following file and then outputting it
>with XMLOutputter:
>
><my_doc>
>  <hf_text>
>    <a href="test"></a>
>  </hf_text>
>  <hf_text>
>    <a href="test"></a>
>    -- URL to the left
>  </hf_text>
>  <hf_text>
>    URL to the right
>    <a href="test"></a>
>  </hf_text>
>  <hf_text>
>    URL to the right
>    <a href="test"></a>
>    URL to the left
>  </hf_text>
></my_doc>
>
>
>The output I get is:
><my_doc>
>  <hf_text>
>    <a href="test" />
>  </hf_text>
>  <hf_text>-- URL to the left</hf_text>
>  <hf_text>URL to the right
>
>    <a href="test"></a>
>  </hf_text>
>  <hf_text>URL to the right
>
>    URL to the left</hf_text>
></my_doc>
>
>

After a quick look, it seems to be a feature not a bug. :-) JDOM does 
not guarantee or even attempt to provide byte-for-byte round trip 
fidelity. If your application depends on byte-for-byte round-trip 
fidelity and it is not an XML editor, then your application is wrong. 
Very few XML tools would preserve all of what you're trying to 
preserve. For instance, from the perspective of XML there is NO 
difference between <a href="test"></a> and <a href="test" />. No 
application should treat these as different.

Some of the white space problems you report are a problem with JDOM, 
not with XML. I agree with you that JDOM should preserve the white 
space. I also claim that the XMl specification requires this. However 
not everyone else agrees with us about this. Perhaps you can convince 
Brett and Jason why this is important. I could not. :-)

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list