Re: [xml] xmlParseDTD with input from memory, in Python



On Tue, Sep 21, 2004 at 04:26:30PM -0400, Fred L. Drake, Jr. wrote:
I'm sorry if this question is answered in the documentation, but I wasn't able 
to find it.

I'm interested in validating a document against a seperate DTD (not referenced 
from the document itself), and I've found the example in the xmllint source.  
The twist, in this case, is that I have the DTD as a string in memory, and 
would like to avoid writing it to an external file if I can.

Is there some way to feed xmlParseDTD (or something equivalent) from a string 
in memory?

I'm using the Python bindings.

  At the C level there is

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

generating an xmlParserInputBufferPtr from a memory string is possible

with 

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

  so this is feasible in C. But there is no direct bindings for those in
Python, automatic mapping of Python I/O to xmlParserInputBufferPtr should
be doable, there is 

PyObject *
libxml_xmlCreateInputBuffer(ATTRIBUTE_UNUSED PyObject *self, PyObject *args)

in the python bindings, but xmlIOParseDTD is not part of the automatically
generated binding, though most of the infrastructure seems in place.

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]