Re: [xml] xmlTextReaderSetSchema and dynamic setting of the schema

On Fri, Feb 09, 2007 at 10:29:39AM -0600, David D. Hagood wrote:
I'd like to check my understanding:

According to the documentation, if you want to have an xmlTextReader do 
schema validation, you have to set the schema before the first read call 
on the text reader.


HOWEVER, if you are trying to make a reader routine which can handle 
multiple document types, you don't know the doc type until you've read 
the DOCTYPE element, which you don't know until you've done a Read on 
the Reader - which makes it too late to activate a schema.

So as I read it, there is no way to read the first 2 lines of a stream 
(which may not be seekable), deduce the schema needed from the DOCTYPE 
record, then activate the appropriate schema.

Is this a correct assessment?

  I think yes. Maybe xmlTextReaderSetSchema could be tweaked to allow
setting it as long as the start tag of the root element has not been
processed, code wise the change might be simple but it would require 
additional testing. Basically it would require replacing:
      if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
in xmlTextReaderSetSchema() by a more lax definition checking where we are
in the reader process within the document.


Red Hat Virtualization group
Daniel Veillard      | virtualization library
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]