Re: [xml] libxml3



On Wed 17 Apr 2002 at 11:35:22 +0200, Peter Jacobi wrote:

One thing I'll like to see (and will see after it when it's
really time for libmxl3):

"visiting" as an alternative to "concatening"

For functions which assemble a new (and newly allocated)
character buffer by concatening several pieces (and probably
reallocating in this process), I would like to have an 
alternative by giving a visitor callback as parameter,
which gets called for each fragment.

That's what the SAX interface provide. With the following document
fragment ...

        <foo>hello<bar>test</bar>world</foo>

... the parser would do the following :

        startElement(user_data, "foo", NULL)
        characters(user_data, "hello", 5)
        startElement(user_data, "bar", NULL)
        characters(user_data, "test", 4)
        endElement(user_data, "bar")
        characters(user_data, "world", 5)
        endElement(user_data, "foo")

So within the "foo" context, you get 2 pieces : "hello" and "world".
IIRC, the rest of the libxml parser is built on top of that interface
using concatening buffers.

Simply give startElement, endElement and characters "visitor" callbacks
to functions such as xmlSAXUserParse{Memory,File}, and you're mostly
done.  :-)  Oh, maybe I didn't understand what you're looking for.

Fernand



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