You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Mark Lassau <ml...@bisinfo.com.au> on 2003/03/24 06:18:40 UTC

Whitespace in top-level of DOM document

I am using Xerces 2.3.0 org.apache.xerces.parsers.DOMParser to 
machine-edit an XML file and save it.
I would like to preserve as much of the original formatting as possible 
(for human readability).
The one annoying problem is that the whitespace before the first tag is 
not reported.

eg a file that looks like:

<xml version="1.0">

<!-- Top-Level Coment -->
<!-- This is where we come unstuck -->

<server>
   ...


Will end up looking like this:

<xml version="1.0">

<!-- Top-Level Coment --><!-- This is where we come unstuck --><server>
   ...



Whitespace elsewhere is reported, and I can keep the formatting.
This appears to be similar to bug 5077 "Report top-level whitespace" 
reported against the XNI component.


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


Re: Whitespace in top-level of DOM document

Posted by Joseph Kesselman <ke...@us.ibm.com>.
The DOM has no way to represent whitespace outside the Document Element. 
Your best bet is to write a serializer that understands how to reconstruct 
that whitespace in a way that matches your preferences.

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more. 
"may'ron DaroQbe'chugh vaj bIrIQbej"  ("Put down the squeezebox and nobody 
gets hurt.")


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