Re: [xml] help! python wrapper for the xslt loader API
- From: Daniel Veillard <veillard redhat com>
- To: Nic James Ferrier <nferrier tapsellferrier co uk>
- Cc: libxml <xml gnome org>
- Subject: Re: [xml] help! python wrapper for the xslt loader API
- Date: Tue, 5 Sep 2006 22:11:13 -0400
On Wed, Sep 06, 2006 at 01:38:06AM +0100, Nic James Ferrier wrote:
I've knocked up a patch for python wrapping the xslt loader API.
My patch facilitates writing loaders in python.
But I'm having problems getting the xmlDocPtr back from a python
function.
[...]
When I do this I don't seem to get a valid doc.
The python I'm using is:
def fn(url, ctx):
try:
# print url
ctxt = libxml2.parserCtxt(_obj=ctx)
doc = ctxt.ctxtReadDoc("""<?xml version='1.0'?><b/>""", url, "UTF-8", 0)
return doc
The C object wrapper is in doc._o, maybe you don't want to have the function
return it, in that case at the C level you may have to grab the _o
except Exception, e:
print >>sys.stderr, "something went wrong:", e
return None
The return value of ctxtReadDoc is a PyCObject wrapped xmlDocPtr so I
presumed that I'd just be able to access it with PyxmlNode_Get. But as
I say... this is not so.
I think there is one more layer :-) sorry for the complexity ...
Anybody know what mantra I need to get at the doc object returned from
python in this instance?
lookup the _o, see libxml2.py especially the xmlDoc constructor.
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]