Re: [xml] setting externelEntityResolver on a per-context basis




Lars Oppermann wrote:
When using xmlCtxtReadIO, how can I make sure that I can also control 
the IO which occurs when an external subset or external DTDs are loaded? 
  While I working with this, it seemed like external entities were only 
being resolved when I had used xmlSetExternalEntityLoader before parsing 
and that setting ctxt.sax.resolveEntity had no effect whatsoever on the 
entity resolution.

So you are absolutely correct that there is no need for me to use 
xmlCtxtReadFile. I can very well do with the ReadIO version. I'm just 
wondering how to get called for resolution of external entities embedded 
in the document that is being parsed...

Is it currently possible in libxml2 to set the external entity resolver 
for an single xmlParserCtxt instead of using 
xmlSetExternalEntityLoader() which seems to be setting it globally?

What we do in lxml is: set a global resolver and have it dispatch to whatever
the _private field in the parser context points to. We actually do a lot more
that way than only resolving external entities, but that's what you can use it
for here.

Stefan




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