Re: [xml] Parsing <?xml decl with xmlReader

On Tue, Nov 15, 2005 at 08:31:44PM +1100, Michael Day wrote:

Hi Daniel,

  No because the code parsing it in xmlParseXMLDecl() does not fire any
SAX event, so any proof of having gone though that path can only be noticed
by the side effects of that routine. It sets ctxt->version, so if you
don't have ctxt->version you can be sure you didn't had an XMLDecl, but
unfortunately I documents are alway created with a version string of 1.0
if no XMLDecl is found, see line 9081 of parser.c

If I submitted a patch to add a hasXmlDeclaration field to the
xmlParserCtxt struct would you consider merging it? :)

  No because there is already too much cruft in it. But adding a special 
value to ctxt->standalone (-2) indicating that the XMLDecl was read but
the standlone information was not present would be okay.

(It would also be possible to add a SAX callback to be called when the XML
declaration is parsed, but this seems like overkill for such a small thing
and would require changing the SAX struct which is a bad thing).

  Don't even think about that. SAX block tend to be allocated by user code
changing the size of that data structure is a definite no-no.


Daniel Veillard      | Red Hat
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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