pulling with expat

Paul Miller stele at fxtech.com
Sun Dec 19 21:30:08 GMT 1999

As promised I decided to take another stab at implementing my streaming
pull-style parser over expat. Either I haven't had enough strong drink
yet for it to make sense, or it's not possible. If you'll recall my
design for the hierarchical nature of the element handlers, I want to be
able to nest my parsing, just like an object hierarchy:

(in XML)


(in class form)

	class Child

	class Parent
		Child *child;

(in parsing form)

	encounter Parent element: call Parent::Parse
	Parent::Parse - install new handlers and look for Child element
	encounter Child element: call Child::Parse
	encounter </Parent>
		------> RETURN BACK TO Parent::Parse <--------
	clean up

(in code)

void Parent::Parse(Element &elem)
	Handler handlers[] = {
		Handler("Child", Child::Parse)
	elem.Parse(handlers, this);
	// now do some stuff before returning control

The major design point is you enter an element handler for a class, that
class does all of its parsing for any sub-elements, and control is
returned back to the handler, allowing it do some cleanup or validation
or whatever the code wants to do.

So far, I just haven't been able to find a way to make expat work this
way. The only way I can see doing it would be to have expat build a tree
of all encountered elements, then process the tree using my interface,
but that goes down the DOM road of excessive memory usage.

I'm hoping someone can point out the obvious thing I'm missing here... 

Paul Miller - stele at fxtech.com

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at 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 at ic.ac.uk the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)

More information about the Xml-dev mailing list