Jamie Lyon wrote:
Yes, I think you're correct. I made the incorrect assumption that
detaching a node detached the node entirely from the original dom tree,
effectively making it independent.
Well in our implementation it does. Once you detach the node, neither
the detached node and it's children, nor the rest of the tree has
references of the other (children of the detached node stays with
it). Thus, you need to do two detach operations to remove any particular
node only. In doing so if you want the namespaces declared above to
be inherited, you have to do it yourself. (However, detach could become a
bit tricky if you are detaching the node while the stax builder is still
building the document.)
In reality I guess what I want is to
be able to clone the node.
In this case, axiom couldn't help much. Such a function is not
implemented in axiom as far as I can see. I agree that having this
function is useful, though.
Basically when I receive the Soap message you obviously get the whole
body, what I want to do is after parsing the majority of it into
relevant data, keep part of it as the original XML -- the metadata.
Keeping the whole document around seems incredibly inefficient memory
wise, so I assumed that disconnecting the node would be suitable, but
when I do this, when I delete the parent some namespace information is
lost.
It is not lost. It just stays with the parent. :)
If you do not need the original axiom tree intact, this is the best way
to do it. That is to detach the node and adding the necessary namespaces
traversing upwards through the axiom tree. Why detach function does not
deal with the namespaces is that there are situations where you do not
need the namespaces to be preserved, but the plain node needs to be
detached.
Unfortunately axiom doesn't have the clone method that DOM specifies
either, so I can't seem to find any solution for this problem - any
ideas?
Even in cloning, there are many different ways one would want the node
to be cloned. For example, with/without refrences to the parent,
children; with/without namespaces inherited; in the namespace inherited
situation, should it inherit only the namespaces that are defined to
itself, or with it's children's, etc. So I guess basically what we should
provide is a basic clone function where a parameter is taken to decide if
the clone should include the children too. IIRC, this is how it is defined
in DOM. User will have to do a little coding to sort out the namespaces as
he prefers.
Regards,
Dumindu.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]