[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] pulling 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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|