Re: [xml] How to extend the Reader interface with a dup() function



On Sun, Nov 02, 2003 at 10:54:01PM +0100, Nanning Buitenhuis wrote:
I want to extend the Reader interface with a dup() function.
That is, make a new reader with the same state as the current
reader, so a trial run over the data is possible.

Possible, impossible, or pointers?

  Would require special code in the xmlreader.c . Seems really hard
anyway for example if you feed the data from a socket. So In general
it sounds like too hard to make reliable and it't better to reuse 
the Reader for the same stream again.

Daniel

That would make the calling code overly complex.
In certain circumstances (XSL-FO parsing) I need to scan ahead and
then continue from the original point onwards. The documents are

  Wouldn't the Expand() operation be sufficient for what you need ?

-potentially- far to big to be stored in core, and rescanning to
my current position would be ugly.

I would not mind at all if the dup() would only work for files and
return NULL for other input streams. Later, perhaps, I could extend
it to other streams.

  That doesn't sound actually possible. It will work for files, but
not for other inputs. what you really want is see more than the current
node for analysis, and I think it's far cleaner to locally expand the 
subtree for analysis than starting to play with parser states or things
like duplicating socket contents (which won't work or won't fit in memory
either).

Or did you have something else in mind when you said
  "it't better to reuse the Reader for the same stream again."
?

  Rescanning from start but reusing the parser.

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]