[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [xml] Does libxml2 create nodes on-the-fly?



On 24.06.06 09:12:47, Daniel Veillard wrote:
> On Sat, Jun 24, 2006 at 12:26:47AM +0200, Andreas Pakulat wrote:
> > On 23.06.06 17:05:08, Daniel Veillard wrote:
> > > On Fri, Jun 23, 2006 at 10:07:20PM +0200, Andreas Pakulat wrote:
> > > > Anybody with a hint, how to check wether 2 nodes are the same?
> > > 
> > >   unfortunately I'm afraid you need to go down to the C level and
> > > check the 2 pointers, they aren't seen at the python level. Should be
> > > a fairly easy change to python/libxml.c to add this equality entry point
> > > and then add a method in the node class in libxml.py to be used for
> > > comparison.
> > 
> > Ok, first I'll open a wishlist bug for this and then I'll try to do this
> 
>   that that's a good first step :-)
> 
> > (though I'm not familiar with libxml2's C Interface, nor the
> > Python-C-Bridge-Stuff in general)...
> 
>   Should be fairly simple, make a C python binding routine based on
> existing ones in python/libxml.c , give it a significant name,
> change the beginning to expect 2 python obect references as arguments,
> see type.h to see how the C object is attached, get the two xmlNodePtr
> associated. Compare them, and return an python 0 or 1, then register
> the new routine at the end of libxml.c

So far, no big deal I think (couldn't test yet, see below).

>   now in libxml.py override the comparator operator to call that routine
> in libxml2mod, add a python test case in test/ and bingo you're done :-)

But this is a bit of a problem. I'd like to use __eq__ and __ne__ on
xmlNode class to implement the equality check without an extra function.
However I don't see how I could add that. libxml.py contains only
functions and no class definitions and libxml2class.txt only contains
method names and no bodies. And I don't really want to try to understand
how the conversion from libxml2class.txt -> libxml2class.py works. Do
you have an idea for this, or do I need to make it a global function?

Andreas

-- 
Good news.  Ten weeks from Friday will be a pretty good day.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]