Re: [xml] python wrapper for document API (AND transformCtxt API)



On Thu, Sep 07, 2006 at 01:40:34AM +0100, Nic James Ferrier wrote:
This is my two recent areas of work combined.

My motivation for building this API was to allow me to identify what
transformation a particular load was occuring for and this patch
enables me to do that. That's why I've combined them... they actually
make sense (to me anyway) together.


It does the following:

- adds a function to create an xslt transformContext from python

- adds a function to apply a stylesheet with a user supplied
  transformContext

- adds a python doc loader which calls a registered python function
  with a URI, xpathParserContext and transformContext and accepts a
  document in return

- adds a function to set the doc loader to a python function

- adds comparison API for transformContext objects


The patch is not complete... but it is usable and I will complete it
by adding these functions:

- a free for transformContext objects

- a getter for the python doc loader function


There are some problems that I could use some help with:

- why is the doc loader context sometimes a stylesheet instead of a
  transformContext?

  can libxslt/libxslt/documents.c::xsltLoadStyleDocument be changed so
  that it creates a transformContext or something?

  You may load files at stylesheet compilation time or at  transformation time
the context are clearly different, and can't be unified...

- when the doc comes back from the python doc loader function do I
  have to DECREF it in some way?

  Can't tell from memory. I guess that when python passes an argument it 
increase the count for the function, but when it's a return value the
count is not incremented.

- if I uncomment the xmlFreeParserCtxt(pctxt) at the end of the
  pythonDocLoaderFuncWrapper I get complaints from libc about double
  free-ing:

    *** glibc detected *** double free or corruption (fasttop): 0x0819a7f8 ***
    Aborted

  I can't see why this is really... I've copied the bones of the
  function from the libxml2 entity loader solution and it doesn't seem
  to have a problem with double free-ing.

  No idea, need debug.

- why could I not get a static cmp function to work as with
  libxml_compareNodesEqual? 

  out of context, what function ?

  There seems to be some difference between the libxml generator and
  the libxslt one?

  well some of it may be error when updating one and not the other, but
also the libxslt one need to support more types, so they aren't really the
same.

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]