Re: [xml] Problems using xmlIOParseDTD() with given encoding



On Tue, Nov 04, 2003 at 01:15:29PM +0100, Keim, Markus wrote:
Hello Daniel, hello all,

i've recently switched to libxml2-2.6.1 and encountered a
problem when using xmlIOParseDTD() to subesequently
validate a document with a given encoding (more precise:
the problem turns up in xmlSwitchToEncoding(), at least
since v2.5.4, but the (new?) error handling using
xmlErrInternal() makes it more obvious).

When calling xmlIOParseDTD(), a brand new xmlParserCtxt is
build and xmlNewIOInputStream() is called with that
context, the given xmlParserInputBufferPtr and encoding.
If the encoding is unequal to XML_CHAR_ENCODING_NONE,
xmlSwitchEncoding() and than xmlSwitchToEncoding() is called,
again with the new parser context and the appropriate
encoding handler (if found).
xmlSwitchToEncoding() now checks (ctxt->input != NULL)
and calls
xmlErrInternal(ctxt, "xmlSwitchToEncoding : no input\n",
                         NULL);
since the newly build context obviously has no input
pointer.
xmlErrInternal() sets ctxt->wellFormed = 0 and after
xmlIOParseDTD() has called xmlParseExternalSubset(),
it checks (ctxt->wellFormed) and returns NULL.

Some debugging in v2.5.4 and v2.6.1 shows that switching
to the given encoding fails in both versions due to the
check of (ctxt->input != NULL), but only v2.6.1 sets
ctxt->wellFormed = 0.

So, for what i currently see it's
- not possible to use xmlIOParseDTD() with a given
  encoding in recent versions of libxml2
- it's possible in prior versions, but the encoding won't
  be took into account

I'm tackling things wrong or is there an actual problem
in libxml2?
And if so, how could it be solved (i don't think that the
check for (ctxt->input != NULL) in xmlSwitchToEncoding()
could be generally dropped)?

  This can't be dropped, can you bugzilla this ?
apparently this need fixing, probably simply by maling sure the input
is actually set-up ...

    thanks,

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/



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