[jdom-interest] JDom 2 Dom, then Dom 2 JDom

Elliotte Rusty Harold elharo at metalab.unc.edu
Thu Jan 17 13:48:59 PST 2002


At 3:58 AM +0900 1/18/02, Xuemin Guan wrote:
>?I posted this problem a few months ago, but, it seems this
>problem remains(BTW, I checked out the CVS today).
>
>The problem: when convert between a JDom tree and a DOM
>tree, if you convert the DOM tree which is converted from a JDom tree,
>back to a JDom tree, exception happens. I played with a few XML files.
>While some files are OK, some are not. It seems the one which has
>an explicit namespace does not convert while. However, if you serialize
>the DOM tree to a harddisk, then build a JDom tree from this file, then
>everything is OK.

I'll have to look at the JDOM code, but based on your report I can 
take a pretty good guess as to what's happening. Probabaly when JDOM 
is building a DOM tree it attaches namespaces to various elements and 
attributes but does not put explicit namespace declaration Attr nodes 
in the DOM document. It should do this. DOM, unlike JDOM, requires 
both namespaces on the elements and namespace declaration attributes 
on the elements. The DOM serializers are smart enough to handle this 
and insert xmlns attributes where necessary, but the JDOM DOMBuilder 
code probably isn't. Anyway, that's my guess.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|              http://www.ibiblio.org/xml/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/     |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list