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



Hi Daniel,
thank you for the prompt response.

There are not a whole lot of example around catalog, translating a SystemID into a new SystemID in particular.
Suppose I go build a catalog. How do I tell the xmlReader to use it with the document I am about to open?

I did not find any examples to this.

Tapping into the I/O with callbacks does not seem to achieve this. At least, the examples I see in io1.c do not help.

Any further hints?

Best regards: Zoltán Ördögh


On Thu, Mar 28, 2013 at 3:51 AM, Daniel Veillard <veillard redhat com> wrote:
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]