[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

pulling with expat

  • From: Paul Miller <stele@f...>
  • To: "Clark C. Evans" <clark.evans@m...>, James Clark <jjc@j...>, xml-dev <xml-dev@i...>, sml-dev@e...
  • Date: Sun, 19 Dec 1999 16:30:51 -0500

with expat
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@f...

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo@i... the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.