[
Lists Home |
Date Index |
Thread Index
]
- From: Sean Mc Grath <digitome@iol.ie>
- To: xml-dev@ic.ac.uk
- Date: Sat, 18 Dec 1999 14:11:43 +0000
Paul,
I would suggest that what you need here is a layer
above Expat that queues up the
"events" generated from expats callbacks for consumption
by your application.
Off the top of my head you could have a top level
GetExpatEvent() entry point that works like this:-
1) If there is an Expat event queued up, it returns in.
2) Otherwise, it feeds more data into Expat until
such time as an event appears in the queue and
then returns that event.
Basically, you would create callbacks for Expat
whose function in life is to add the event information
to a queue which you then consume from the
GetExpatEvent() entry point.
>> When I get to the handler, I'd like to write this:
>>
>> void PointHandler(XML::Element &elem, Point *point)
>> {
>> // "pull" a chunk of element data, but it'll automatically
>> // stop when it gets to the end of the element (it stops
>> // when it sees </Point>)
>> char buf[40];
>> elem.GetData(buf, sizeof(buf));
>> sscanf(buf, "%dx%d", &point->x, &point->y);
>> }
>>
>> For some reason I couldn't figure out how to make this work, because
>> with expat I might have hit the element but not necessary gotten to the
>> character data handler.
>
>I remembered why I couldn't get this part to work. Suppose (using expat)
>I get to the <Point> element. So far I can build the tree down to this
>point, so when I see <Point> I look in the handler list for that subtree
>and call the callback for the Point element. Now in PointHandler, the
>code wants to pull the element data. I can't go back into expat and
>parse some more at this point, getting called back with expat's
>CharacterData handler, fill my buffer, and fall back out to
>PointHandler.
>
>But this brings up a question: does expat buffer the entire character
>data itself? If it does, perhaps I could delay the call to PointHandler
>until after the expat character data handler has been called. I can save
>a copy of that pointer away in my Element list, and only call the user
>code when I see the end element tag.
>
>Does this sound workable?
>
>--
>Paul Miller - stele@fxtech.com
>
Sean,
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo@ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)
|