[xml] Adding new slot in parser.h::_xmlParserCtxt


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;

After that, I get the `segmentation fault' somewhere (I really don't know where, because it changes depending on where I place the `loaderId' slot in '_xmlParserCtxt'). How can I implement what I needed and what is happening when I add a new slot in _xmlParserCtxt? There was a similar trouble when I added `loaderId' as the first slot to _xmlDoc, and I fixed it by moving it to the bottom of the structure. The problem was that `xmlElementType' must be the second slot. But there are no similar restrictions in `_xmlParserCtxt'.


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