RE: [xml] In-memory catalog



Daniel,

Thanks for the information. I tried your approach, and use
xmlParserInputBufferCreateMem() (see below) in my custom entity loader.
But xmlParseFile() always returns NULL if I do that. Can't I use
xmlParserInputBufferCreateMem() for this ?
Also, is there a way to pass some information in the xmlParserCtxtPtr to
the entity loader (the doc says it's SAX only).

- Daniel

...
// redirect external entity loader
defaultLoader = xmlGetExternalEntityLoader();
xmlSetExternalEntityLoader(externalEntityLoader);
...

xmlParserInputPtr externalEntityLoader(const char* url, 
                                       const char* id, 
                                       xmlParserCtxtPtr ctxt)
{
  if (url && stricmp(url, "http://myhost/DTD/1.0/mydtd.dtd";) == 0) {
    xmlParserInputPtr input = xmlNewInputStream(ctxt);
    input->filename = NULL;
    input->directory = NULL;
    input->buf = xmlParserInputBufferCreateMem(g_dtd, g_dtdLen,
XML_CHAR_ENCODING_ASCII);
    input->base = input->buf->buffer->content;
    input->cur = input->buf->buffer->content;
    input->end = &input->buf->buffer->content[input->buf->buffer->use];
    return input;
  }
  else
    return (*defaultLoader)(url, id, ctxt);
}



-----Original Message-----
From: xml-admin gnome org [mailto:xml-admin gnome org] On 
Behalf Of Daniel Veillard
Sent: Friday, 05 April, 2002 19:50
To: Daniel Gehriger
Cc: xml gnome org
Subject: Re: [xml] In-memory catalog


On Fri, Apr 05, 2002 at 07:21:01PM +0200, Daniel Gehriger wrote:
Hello,

I'm defining a XML doctype to be used only by one of my 
applications. 
I would like to use the DOCTYPE as an external subset in the XML 
files:

...
<!DOCTYPE FXML SYSTEM "http://myhost/DTD/1.0/mydtd.dtd";>
...

While I can (and will) store the DTD at the specified URL, I would 
like my applications to use a local copy of it. That's what 
catalogs 
are for, right ? Ok, but I don't want to install a catalog file, as 
this adds one more file that will break the application if it is 
missing. Rather, I

  Then simply override the default entity loader to make it point 
to your in-memory resource:
    http://xmlsoft.org/xmlio.html#entities

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  
http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/ _______________________________________________
xml mailing list, project page  http://xmlsoft.org/ xml gnome org
http://mail.gnome.org/mailman/listinfo/xml




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