[libxml++] Patch for libxml++ (was Re: Parsing streams of XML)



Stefan Seefeld <seefeld sympatico ca> writes:

> Ole Laursen wrote:
> 
> > So each of these <message> and <presence> elements are small documents
> > in themselves. If I could get a DOM-representation of each of them, it
> > would somewhat easier I think. Any hints?
> 
> well, these chunks are not valid xml documents in themselfs, so you have
> to treat them as parts of a parent document. Libxml2 supports parsing of
> chunks, and I think what you are looking for is really an event driven
> approach, where your sax handler is called per tag that is encountered
> in the stream. Libxml++ doesn't provide chunk-wise parsing yet...

Well, if it has to be SAX, it has to be SAX. Anyway, making state
machines are fun, it's just the maintaining part I fear. :-)

However, the lack of chunk-wise parsing is a show-stopper. I can't
derive from SaxParser since all the sexy details are kept private.
What about extending the interface?

AFAICS, all it needs is:

  virtual void parse_chunk(const std::string& chunk) throw(exception);
  virtual void finish_chunk_parsing() throw(exception);

The contents of parse_chunk can be stolen almost verbatim from
parse_stream. I've put a small patch (with documentation and example)
here:

  http://www.cs.auc.dk/~olau/misc/libxml++.patch

Any chance of getting it in?

-- 
Ole Laursen
http://www.cs.auc.dk/~olau/




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