List Info

Thread: Does libxml2 create nodes on-the-fly?




Does libxml2 create nodes on-the-fly?
user name
2006-06-20 16:25:05
Hi,

> -----Original Message-----
> From: xml-bouncesgnome.org [mailtoml-bo
uncesgnome.org] On 
> Hi,
> 
> still using the python bindings...
> 
> It seems that I always get new python objects everytime
I ask for
> node.children, is that correct? This makes it rather
hard to 

Yes, this is the intended behaviour; otherwise one would
have to
implement reference counting or keep the python wrapper
objects
for Libxml's nodes always alive.

DOM Level 3 introduced the method "isSameNode"
for such scenarios:
http://www.w3.org/TR/2004/REC-DOM-Level-
3-Core-20040407/core.html#Node3-
isSameNode

> look for a
> specific node within the tree, given the node as a
result of say an
> xpath expression. Do I miss anything?
> 
> Andreas

Regards,

Kasimier
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Does libxml2 create nodes on-the-fly?
user name
2006-06-20 18:00:37
On 20.06.06 18:25:05, Buchcik, Kasimier wrote:
> Hi,
> 
> > -----Original Message-----
> > From: xml-bouncesgnome.org [mailtoml-bo
uncesgnome.org] On 
> > Hi,
> > 
> > still using the python bindings...
> > 
> > It seems that I always get new python objects
everytime I ask for
> > node.children, is that correct? This makes it
rather hard to 
> 
> Yes, this is the intended behaviour; otherwise one
would have to
> implement reference counting or keep the python wrapper
objects
> for Libxml's nodes always alive.

Ah, so libxml2's python bindings go the easy route 

> DOM Level 3 introduced the method
"isSameNode" for such scenarios:
> http://www.w3.org/TR/2004/REC-DOM-Level-
3-Core-20040407/core.html#Node3-
> isSameNode

Well, nice to know there is a way in theory, but how about
libxml2's
actual set of functions? I couldn't find anything with the
libxml2
module. So does libxml2 (the python bindings) provide any
means of
checking wether 2 nodes are the same wrt. to the dom? 

Andreas

-- 
Love is in the offing.  Be affectionate to one who adores
you.
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Does libxml2 create nodes on-the-fly?
user name
2006-06-23 20:07:20
On 20.06.06 20:00:37, Andreas Pakulat wrote:
> On 20.06.06 18:25:05, Buchcik, Kasimier wrote:
> > > It seems that I always get new python objects
everytime I ask for
> > > node.children, is that correct? This makes it
rather hard to 
> > 
> > Yes, this is the intended behaviour; otherwise one
would have to
> > implement reference counting or keep the python
wrapper objects
> > for Libxml's nodes always alive.
> 
> > DOM Level 3 introduced the method
"isSameNode" for such scenarios:
> > http://www.w3.org/TR/2004/REC-DOM-Level-
3-Core-20040407/core.html#Node3-
> > isSameNode
> 
> Well, nice to know there is a way in theory, but how
about libxml2's
> actual set of functions? I couldn't find anything with
the libxml2
> module. So does libxml2 (the python bindings) provide
any means of
> checking wether 2 nodes are the same wrt. to the dom? 

Anybody with a hint, how to check wether 2 nodes are the
same?

Andreas

-- 
You're currently going through a difficult transition
period called "Life."
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Does libxml2 create nodes on-the-fly?
user name
2006-06-23 21:05:08
On Fri, Jun 23, 2006 at 10:07:20PM +0200, Andreas Pakulat
wrote:
> On 20.06.06 20:00:37, Andreas Pakulat wrote:
> > On 20.06.06 18:25:05, Buchcik, Kasimier wrote:
> > > > It seems that I always get new python
objects everytime I ask for
> > > > node.children, is that correct? This
makes it rather hard to 
> > > 
> > > Yes, this is the intended behaviour;
otherwise one would have to
> > > implement reference counting or keep the
python wrapper objects
> > > for Libxml's nodes always alive.
> > 
> > > DOM Level 3 introduced the method
"isSameNode" for such scenarios:
> > > http://www.w3.org/TR/2004/REC-DOM-Level-
3-Core-20040407/core.html#Node3-
> > > isSameNode
> > 
> > Well, nice to know there is a way in theory, but
how about libxml2's
> > actual set of functions? I couldn't find anything
with the libxml2
> > module. So does libxml2 (the python bindings)
provide any means of
> > checking wether 2 nodes are the same wrt. to the
dom? 
> 
> 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.

Daniel

-- 
Daniel Veillard      | Red Hat http://redhat.com/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Does libxml2 create nodes on-the-fly?
user name
2006-06-23 22:26:47
On 23.06.06 17:05:08, Daniel Veillard wrote:
> On Fri, Jun 23, 2006 at 10:07:20PM +0200, Andreas
Pakulat wrote:
> > On 20.06.06 20:00:37, Andreas Pakulat wrote:
> > > On 20.06.06 18:25:05, Buchcik, Kasimier
wrote:
> > > > > It seems that I always get new
python objects everytime I ask for
> > > > > node.children, is that correct?
This makes it rather hard to 
> > > > 
> > > > Yes, this is the intended behaviour;
otherwise one would have to
> > > > implement reference counting or keep the
python wrapper objects
> > > > for Libxml's nodes always alive.
> > > 
> > > > DOM Level 3 introduced the method
"isSameNode" for such scenarios:
> > > > http://www.w3.org/TR/2004/REC-DOM-Level-
3-Core-20040407/core.html#Node3-
> > > > isSameNode
> > > 
> > > Well, nice to know there is a way in theory,
but how about libxml2's
> > > actual set of functions? I couldn't find
anything with the libxml2
> > > module. So does libxml2 (the python bindings)
provide any means of
> > > checking wether 2 nodes are the same wrt. to
the dom? 
> > 
> > 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
(though I'm not familiar with libxml2's C Interface, nor
the
Python-C-Bridge-Stuff in general)...

Andreas

-- 
The whole world is a tuxedo and you are a pair of brown
shoes.
		-- George Gobel
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Does libxml2 create nodes on-the-fly?
user name
2006-06-24 13:12:47
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
  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 

Daniel

-- 
Daniel Veillard      | Red Hat http://redhat.com/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Does libxml2 create nodes on-the-fly?
user name
2006-06-24 14:16:58
On 24.06.06 09:12:47, Daniel Veillard wrote:
> On Sat, Jun 24, 2006 at 12:26:47AM +0200, Andreas
Pakulat wrote:
> > (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
>   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 

Thanks for the extensive information, I just got another
hour free time
and will try.

Andreas

-- 
You work very hard.  Don't try to think as well.
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Does libxml2 create nodes on-the-fly?
user name
2006-06-24 15:19:02
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.
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Does libxml2 create nodes on-the-fly?
user name
2006-06-25 19:56:26
On 24.06.06 09:12:47, Daniel Veillard wrote:
> > (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

I had a shot now and also found xmlCore in libxml.py, where
I could
provide __eq__ and __ne__. However somehow comparing the
xmlNodePtr's
doesn't really work. Even for unequal python xmlNode's a

xmlNodePtr1 == xmlNodePtr2 

returns true.

And I'm stuck there now, because I don't really know what
else I could
use to compare the nodes... See Bug number 345779 for the
patches.

Andreas

-- 
You don't become a failure until you're satisfied with
being one.
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Does libxml2 create nodes on-the-fly?
user name
2006-06-26 08:39:05
On 24.06.06 09:12:47, Daniel Veillard wrote:
> On Sat, Jun 24, 2006 at 12:26:47AM +0200, Andreas
Pakulat wrote:
> > (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
>   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 

Hmm, this thread looks interesting now 

Thanks to William Brack I could create a proper patch that
enables
comparison of Python objects derived from xmlCore (i.e.
xmlNode and all
subclasses). The bugreport is 345779 and I hope it'll make
it into some
not-so-distant future version of libxml2.

Andreas

-- 
You will forget that you ever knew me.
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-10] [11-12]

about | contact  Other archives ( Real Estate discussion Medical topics )