OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   pulling with expat

[ Lists Home | Date Index | Thread Index ]
  • From: Paul Miller <stele@fxtech.com>
  • To: "Clark C. Evans" <clark.evans@manhattanproject.com>, James Clark <jjc@jclark.com>, xml-dev <xml-dev@ic.ac.uk>, sml-dev@egroups.com
  • Date: Sun, 19 Dec 1999 16:30:51 -0500

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)

	<Parent>
		<Child>
		</Child>
	</Parent>

(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
		(here is the key!) DO NOT RETURN UNTIL CHILD HAS BEEN PARSED!
	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)
		Handler::END
	};
	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@fxtech.com

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)






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS