Re: [xml] Adding new slot in parser.h::_xmlParserCtxt
- From: Rob Richards <rrichards ctindustries net>
- To: Lilith <lilith zenteq am>
- Cc: xml gnome org
- Subject: Re: [xml] Adding new slot in parser.h::_xmlParserCtxt
- Date: Sat, 16 Jun 2007 18:02:47 -0400
Hi Lilith,
Lilith wrote:
Hello,
I use libxml2, libxslt, and libxml2-python. In some tasks I need to
redefine the default entity loader. My application runs in multithreaded
mode, and each thread must have a different loader . Also imported and
included stylesheets must be loaded with the same loader as their parent
stylesheet. To implement this, I did the following:
1) added new `loaderId' slot in libxml2::include/libxml/tree.h:_xmlDoc
structure;
2) added new `loaderId' slot in libxml2::include/libxml/parser.h:
_xmlParserCtxt;
3) modified function `xsltDocDefaultLoaderFunc' changing the type of the
fourth argument to `xsltStylesheetPtr ctxt' and added the following:
pctxt = xmlNewParserCtxt();
/* hacked */
if (ctxt) {
par = ctxt->parent;
loaderId = ctxt->doc->loaderId;
pctxt->loaderId = doc->loaderId = (xsltStylesheet *)ctxt->doc->loaderId;
}
to `xsltDocDefaultLoaderFunc' (and modified every call of this function to
pass the right argument);
4) added accessors for `loaderId' to the python wrappers in `parserCtxt'
and `xmlDoc' classes;
If its the external entity loader you need to manage, within PHP, I use
xmlParserInputBufferCreateFilenameDefault. Its per thread and allows me
to take control of input handling for URIs, so we can use the PHP stream
handlers for I/O without possible hijacking from outside sources. It is
called by xmlNewInputFromFile and ultimately from
xmlDefaultExternalEntityLoader. The xsl extension, as it depends on
libxml2 ends up relying upon the custom handling as well.
Rob
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]