Re: [xslt] How do I stop I/O?

On Wed, Aug 18, 2004 at 03:53:30PM -0700, David Hyatt wrote:
> The problem I was running into is that I/O still occurs if I try to 
> stop I/O this way...
> static int matchFunc(const char* URI)
> {
>     return 1; // Match everything.
> }
> static void* openFunc(const char * URI) {
>     return NULL; // Don't ever allow the open.
> }
> ....
> xmlRegisterInputCallbacks(matchFunc, openFunc, NULL, NULL);
> ========
> In the case of imported/included stylesheets, my match/open functions 
> get called, but if I return NULL from the openFunc, it looks like 
> libxslt goes ahead and reads the file itself anyway.  This may become a 
> non-issue once I start using the docLoaderFunc, but I'd still like a 
> bulletproof way of guaranteeing that libxml isn't doing any I/O.

Well libxml2 tries to open the next match if the openFunc failed, which
considering it's user provided functions is safer in general, so you fallback
to libxml2 default routines. Just do at startup:

  int ret;

  do {
      ret = xmlPopInputCallbacks()
  } while (ret >= 0);

Will remove all default I/O from libxml2. Then register your own if you
want to be sure libxml2 never makes any I/O and check what's going on.


Daniel Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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