Re: [xml] How to override SystemID in xmlReader?



On Tue, Mar 26, 2013 at 03:48:13PM -0400, Zoltán Ördögh (GMail) wrote:
Hi all,
I am looking for a legal, built-in solution to override the SystemID in an
XML document without having to patch the document on-the-fly myself; I want
to avoid sting crunching when we have an advanced parser already.

I.e.:
xmlTextReaderPtr _ptrxmlReader=xmlReaderForFile(_sFilename.c_str(),
_sEncoding, XML_PARSE_RECOVER, _sNewSystemID);

I know it does not exist, this is just to illustrate what I want to achieve
- not necessarily like this, but in way that's already in libxml.

Below, you can find the problem description.

The XML is generated on a machine, where the DTD may be located in, for
example: ~/tool/sample.dtd , resulting in:
<!DOCTYPE xmlexport SYSTEM "file:///~/tool/sample.dtd">

The XML may be processed on other machines as well - where the DTD may be
located elsewhere (e.g. /bin/tool/sample.dtd) - and then libxml
(rightfully) throws an error because it did not find the DTD.
The 'tool' knows its own location, so it could provide the new SystemID to
the XML reader.

Any tips?

Could this be added to libxml itself (as new reader constructors)?

  Hum, catalogs are done exactly for this:
    http://xmlsoft.org/catalog.html

otherwise just override the I/O handling something along the lines of
what is presented in:
  http://xmlsoft.org/examples/index.html#io1.c

Daniel

-- 
Daniel Veillard      | Open Source and Standards, Red Hat
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/


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