- From: Guven Demir <guven.internet@gmail.com>
- Date: Wed, 19 Mar 2008 14:39:28 +0200
- To: www-dom@w3c.org
- Message-ID: <eb2d0f0803190539ge138e11xc41213f5a9d7caa2@mail.gmail.com>
Hi all, I failed to understand how DOM models whitespace before the document element. E.g. in the following fragment, the white space between the XML declaration and the starting tag of the <root> element: <?xml version="1.0" encoding="UTF-8"?> <root> <child /> </root> When I parse such a document and get the DOM objects using DocumentBuilder (in java), then later write the objects back to a file using Transformer, the whitespace is preserved. But I cant see the object responsible for the whitespace in the DOM object tree. And also, when I try to insert a text element before the document element I get an exception indicating "HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted." This is consistent with DOM level1 spec, as text nodes dont seem to This means that I cant insert whitespace before the document element when I'm programmatically creating the document, and my document becomes: <?xml version="1.0" encoding="UTF-8"?><root> <child /> </root> Though identical in semantics, it does not look very good and readable. Any ideas or knowledge on this? Thanks in advance, guven
Received on Thursday, 20 March 2008 04:23:39 UTC