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



Hi Daniel,

It is true, that in my case xmlCtxtReadIO is most appropriate. I stumbled upon this, because the difference between
_xmlParserCtxt.sax.resolveEntity and
xmlSetExternalEntityLoader() are not entirely clear to me.

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...

Thanks,
Lars


Daniel Veillard wrote:
On Mon, Jul 02, 2007 at 12:11:53PM +0200, Lars Oppermann wrote:
Hi All,

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?

  I don't think it's possible, look at the struct _xmlParserCtxt there
is no way to plug a resolver there.

I have tried setting ctxt->sax->resolveEntity to my resolve function, but that isn't getting used when I use xmlCtxtReadFile() with that context.

  Why are you using xmlCtxtReadFile() when obviously you loose the
control while there are function working for example from a file descriptor ?

Daniel



--
Sun Microsystems                Lars Oppermann <lars oppermann sun com>
Nagelsweg 55                    Software Engineer
20097 Hamburg, Germany          Phone: +49 40 23646 959
http://www.sun.com/             Fax:   +49 40 23646 550
-----------------------------------------------------------------------
Sitz der Gesellschaft: Sun Microsystems GmbH, Sonnenallee 1,
D-85551 Kirchheim-Heimstetten, Amtsgericht Muenchen: HRB 161028
Geschaeftsfuehrer: Marcel Schneider, Wolfgang Engels, Dr. Roland Boemer
Vorsitzender des Aufsichtsrates: Martin Haering



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