[xml] using XSLT and extension XPath functions, in python



Daniel Veillard wrote:
  Standard, no. You can register functions at the C level to the
XPath core, that exactly what the libxslt library does when it is
initialized. I think this should be doable at the python level too
by calling the XSLT initialization function.

Thanks, but which is the XSLT initialization function? :-)
I couldn't find it in the docs so I am looking for some static initialization in libxslt.py (l-1.0.23-1) but I only see the RTLD stuff on top...

Could you please provide some example for using XSLT functions in a standalone XPath query in python?

By the way, what is the best way to serially process multiple XML documents and run one or more XPath queries over each of them?

I tried getting a new XPath context from each document but after some parses I get this error when registering the python extension function I need on the new context:

libxml_registerXPathFunction() table full

I also tried unregistering the extension function before disposing the context and getting a new one for the next parse but I still get the same error after a few parses.

So now I keep the same context, register the XPath extension function once and iteratively set the doc on it and run the query but I wonder if doing it this way leads to memory leaks or inefficiency by any chance.... (I plan to intensively test this real soon anyway :)

I am using libxml2-python-2.4.30

Thanks, ciao
ste





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