Re: libxml2 application data
Petr Pajas <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Organization | UFAL MFF UK |
| Message-ID | <[email protected]> |
Dne Monday 22 December 2008 14:48:20 philippe marguinaud napsal(a): > Hi Petr, > > I have thought about using the $$node trick, but when the XML tree is > modified ( for instance when a node is deleted ), then some of the nodes > are re-numbered. No, I doubt they get re-numbered as you put it. A scenario that I can think of is that you remove a node from the DOM and create a new one. In such a case of course the new node can take the memory address left by the old one, provided the old node was destroyed, and thus the new node's $$node would be equal to the old one. You have to take care of such cases in your code (e.g. before you make a DOM operation that destroys a node, you should remove the associated data from your hash). > I can provide a demo script to illustrate this if you > want. please do if you can think of some other case. > So I am stuck with XML::LibXML, I will have to find another module. > > Regards, > Philippe I'm sorry. XML::LibXML does not currently provide the feature you ask for. I suggested a possible work-around. Other module may better suit your needs, I don't know them. But if you decide to implement user data over XML::LibXML, here are a few further suggestions: You may wrap the critical DOM functions to deal with user-data transparently. If you do this meticulously, you can either replace XML::LibXML's DOM calls or create a new DOM layer on top of XML::LibXML. This all can be done in your application without modifying XML::LibXML itself. You may also experiment with XML::LibXML's source code and find an way to implement user data inside XML::LibXML (either using _private or otherwise). I usually take patches for new features that make sense and that include self-tests and documentation. Any effort is welcome. -- Petr > > From: [email protected] > > To: [email protected] > > Subject: Re: libxml2 application data > > Date: Mon, 22 Dec 2008 12:14:20 +0100 > > CC: [email protected] > > > > No, XML::LibXML uses the _private slot for its own purposes. I'd > > suggest using a Perl hash and $$node as key ($$node is an integer > > that uniquely identifies a libxml2's node). > > > > -- Petr > > > > On ne 21. prosince 2008, philippe marguinaud wrote: > > > Hi all, > > > > > > I have written C programs using libxml2 and used to attach > > > application data to xml nodes using the _private field of node > > > structs. I would like to know whether it is possible to do that > > > using the Perl bindings; I have not seen anything like that in > > > the pod documentation. > > > > > > Regards, > > > > > > Philippe > > > > > > _________________________________________________________________ > > > Invite your mail contacts to join your friends list with Windows > > > Live Spaces. It's easy! > > > http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/fr > > >iends.aspx&mkt=en-us > > _________________________________________________________________ > Drag n’ drop—Get easy photo sharing with Windows Live™ Photos. > > http://www.microsoft.com/windows/windowslive/photos.aspx _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs