>>>>> "Matt" == Matt Sergeant <[EMAIL PROTECTED]> writes:

Matt> I don't think that's true - or I'm misunderstanding what you're
Matt> saying. When I go:

Matt> $node->appendChild($othernode);

Matt> it calls $$node->appendChild($othernode), and appends the actual othernode
Matt> onto the list of children. So whenever you're iterating over children
Matt> you're getting the actual node, not the sub-node.

I'm talking about the return from ->find, like so:

my $xp = XML::XPath->new(filename => 'test.xhtml');
my $found_node = $xp->find('/html/body/p');

Now, $found_node is either a wrapper or the 'true' object.  If it's
the true object (part of the $xp tree), and I let $xp go out of scope
before $found_node, that should start your destruction of the tree
that includes $found_node, which means my data gets blasted even
though I've got a pointer into it.  Or, if you don't forcefully
destroy the data, you'll leave me pointing to a self-referencing data
structure, which will be a memory leak when I finally toss
$found_node.

If $found_node is instead a wrapper, you've got to have both of the
wrappers communicating to know that one is still "out there" even when
the other goes out of scope.

And $found_node can't be a deepcopy of the data, because you permit
changes via the noderef, so no. :)

I thought a lot about this already.  There's no easy solution, short
of weakrefs, and even those don't solve all of these problems. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

---
You are currently subscribed to perl-xml as: [[email protected]]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to