----- Original Message -----
Sent: Monday, February 10, 2003 8:21
AM
Subject: [dom4j-user] Bug in remove
functions?
(I posted this msg för about a month ago but did not get any feed back,
henc repost...)
Hi
I got a document that look like this:
<?xml version="1.0"
encoding="UTF-8"?>
<root>
<author name="James"
location="UK">James Strachan</author>
<author name="Bob"
location="US">Bob
McWhirter</author>
</root>
<?kalle
kalle?>
What I want to do is to move the Process
instruction to be located right after the xml tag
(<?xml....?>).
I can do this with these
lines:
Node el =
document.getRootElement().detach();
document.add(el);
And the result is like
this:
<?xml version="1.0"
encoding="UTF-8"?>
<?kalle kalle?>
<root>
<author name="James"
location="UK">James Strachan</author>
<author name="Bob"
location="US">Bob
McWhirter</author>
</root>
And this is correct. BUT if I instead
do:
Node el =
document.getRootElement().detach();
document.setRootElement((Element)el);
The result looks like
this:
<?xml version="1.0"
encoding="UTF-8"?>
<root>
<author name="James"
location="UK">James Strachan</author>
<author name="Bob"
location="US">Bob
McWhirter</author>
</root>
As you can see the Process instruction
(<?kalle kalle?>) is removed and it should not be since I only detached
the rootelement and only set a new root element...
Is this a bug in dom4j or have I missed
something in the implementation?
Thankfull for any
input!
Cheers Christian
Holmqvist