[xslt] No user context available when apply stylesheet loads an external entity



Hi,

I have an application that uses libxml2 to parse an XML file, then uses libxslt to apply one or more XSL stylesheet transformations to the document. The result of this is then extracted as a HTML string and given to a web browser control to display.

I have registered an external entity loader with libxml by calling xmlSetExternalEntityLoader(). I have a set of search paths that are registered, and the loader function handles searching them in the proper order.

The problem that I have is that I need to have multiple windows open, each of which displays a separate XHTML document. Each window can have its own set of search paths for file loading. This means that when my external entity loader is called, I need to have enough context so that I can find the proper set of search paths.

For parsing the XML file, I discovered and started using xmlCtxtReadFile(). I allocate a parser context, use the _private data member to store my context, then retrieve it in the entity loader.

However, when I apply a XSL stylesheet transformation to my document, using xsltApplyStylesheetUser(), it often loads other XHTML source files. This calls the loader, but the parser context that is passed in has no context information that I can use to find the correct path set. The myDoc member has a value of 0, and there is no pointer to the xsltTransformContext, so I can't get at its _private data member. I also tried setting the _private data member in the transform context, hoping that it might be propagated to the parser context, but that doesn't happen.

Have I missed something here? How am I supposed to know my application context when I am in the entity loader? I suppose I could guard the XSL transformation with a semaphore, and set the context info into some global location that the loader can retrieve from, but that seems like a nasty hack.

I am using libxml2-2.6.19 and libxslt-1.1.14.

Thanks,
Rush


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