xerces-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Torkel Dominique" <torkel.domini...@hotsip.com>
Subject preserve white spaces outside the root-element
Date Wed, 13 Jul 2005 09:21:58 GMT
Hi,

I recently discovered that when parsing an XML document using DOM with
"include-ignorable-whitespace" feature on (which is default), all white
space located outside the root element is still lost! For example, a
trailing new line character at the end of the document will be lost, as
well as linefeeds between comments before the root element. This is a
problem (although a cosmetic one) when you parse a document and then
serializes it. The output will not be the same as the input.

Example:

<?xml version="1.0"?>
<!-- comment 1 -->
<!-- comment 2 -->
<root>
Some data
</root>

Will after parsing/serialization become

<?xml version="1.0"?>
<!-- comment 1 --><!-- comment 2 --><root>
Some data
</root>

Is this a bug in the parser or perhaps in DOM? Any workarounds?
I have tried xerces 2.6.2 and 2.7.0 with JAXP 1.3 with the same result.

Thanx,
Torkel


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Mime
View raw message