Re: [xml] libxml2 newbie question about the Reader API



Hi Daniel. Thanks for your fast answer!

On Thu, 17 Feb 2005 16:16:40 -0500, Daniel Veillard <veillard redhat com> wrote:
On Thu, Feb 17, 2005 at 08:59:24PM +0100, Aron Stansvik wrote:
Hello xml readers.

Because of some peoples misuse of XML, I'm now writing a simple
wxWidgets application that needs to process huge XML documents. I've
tested that the libxml2 Reader API can handle the load well.

Now I want my application to give some kind of progress feedback to
the user. Is there a way to obtain the number of bytes read when using
a Reader obtained using the simple xmlReaderForFile() function, or
will I have to set up my own custom I/O handlers with
xmlReaderForIO()? I can't find any example usage of this function
anywhere, and I having a bit of a hard time deciphering how it
actually works. Googling for "xmlReaderForIO" only gives 10 hits (!).

My plan is to just stat() the file for it's size before processing it,
and then use the number of bytes read to calculate progress, so all I
need is the position in the input stream that libxml2 uses.

 There is number of simplifications in your approach, like external
parsed entities, encoding conversions.

I know I know, it would be horribly inaccurate if it wasn't for the
fact that I know the exact anatomy of the XML documents I'll be
processing, they are very flat and homogenous. Now it'll just be,
ehum, inaccurate :) The progress information isn't a dead requirement,
just a bonus, and I don't feel like spending any more time
implementing it than I have to. It won't have an ETA count, just a
progress bar the poor user can look at every once in a while and see
that it's doing something.

 http://xmlsoft.org/html/libxml-parser.html#xmlByteConsumed
 From a normal parser you can call this. This is more complex
than you may think. I don't think on can get the parsr from a reader
but the option exists.

If I can't get the parser context from a reader, then the option of
using xmlByteConsumed() doesn't exist. What option are you referring
to? :/

Greatful for any advice and examples of using custom I/O with the
Reader API. I've looked at the custom I/O code samples at xmlsoft.org,

 It's like the I/O from other APIs !

   http://xmlsoft.org/xmlio.html#Example2
   http://xmlsoft.org/examples/index.html#InputOutput

Ah, I somehow missed that first link, thanks. The color scheme and
layout of xmlsoft.org isn't really top-notch IMHO ;)

Thanks again. I'll have to think this over. How would you go about
implementing coarse progress information for a reader?

Aron



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