Re: [xml] parsing "external dtd" from memory?



On Tue, Jul 05, 2005 at 10:32:17PM -0600, Sebastian Kuzminsky wrote:
Hi folks, it'd be really convenient for me to parse an "external"
dtd from memory instead of from a file.  Right now I'm parsing a full
document from memory, and caching its internal DTD, and using that DTD
to validate later documents.

Is there a better way?

  You can parse a DTD standalone:
    from <libxml/parser.h>
  XMLPUBFUN xmlDtdPtr XMLCALL
                xmlParseDTD             (const xmlChar *ExternalID,
                                         const xmlChar *SystemID);
to load from a file.

  XMLPUBFUN xmlDtdPtr XMLCALL
                xmlIOParseDTD           (xmlSAXHandlerPtr sax,
                                         xmlParserInputBufferPtr input,
                                         xmlCharEncoding enc);

   http://xmlsoft.org/html/libxml-parser.html#xmlIOParseDTD

  pass sax == NULL, an input made from your memory string and 
XML_CHAR_ENCODING_NONE. 

  To create an input buffer from a source see <libxml/xmlIO.h>

  XMLPUBFUN xmlParserInputBufferPtr XMLCALL
        xmlParserInputBufferCreateMem           (const char *mem, int size,
                                                 xmlCharEncoding enc);

   http://xmlsoft.org/html/libxml-xmlIO.html#xmlParserInputBufferCreateMem

Daniel
-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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