expat tree-builder (dom)

Andy Dent dent at oofile.com.au
Sat Jan 29 05:09:03 GMT 2000

Hi Doug
>Since my post, I was pressured to produce something, so I built something
>that sounds similar... a limitted  C++ wrapper around expat with utilities
>to configure the callbacks for you and collect tags and attributes interest.
The main added benefit of expatpp is the "sub-parser" model.

Parsing our report files is quite complex as we can nest multiple reports
within a single file and each report has independent
- report layout
- text styles attached to layout items
- adorners - serialised user code with user-saved data and signatures so
people can have
  shaders with their own logic.
- database schema
- data to import into the schema

Debugging this nested set of tags looked like a nightmare so I put a bit of
time into the sub-parser model. The static methods which are the callbacks
automatically handle the nesting depth so will return from the sub-parser
when it reaches its end tag. This vastly simplifies what the sub-parser has
to do. If it only needs to know a couple of tags within its domain then
that's all it evaluates in the startElement etc.

That also improves efficiency because you can optimise the checking of tags
for the most probable in a small locale. Our layout parser knows that it
will encounter <box> tags (CSS term used here to describe a box in which
<inline> elements are laid out) more often than others so can check for
them first.

With the sub-parsers having such limited domains we also are able to check
our output code rigorously by putting lots of asserts in the sub-parsers.

Andy Dent BSc MACS AACM, Software Designer, A.D. Software, Western Australia
OOFILE - Database, Reports, Graphs, GUI for c++ on Mac, Unix & Windows
PP2MFC - PowerPlant->MFC portability

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/ or CD-ROM/ISBN 981-02-3594-1
Unsubscribe by posting to majordom at ic.ac.uk the message
unsubscribe xml-dev  (or)
unsubscribe xml-dev your-subscribed-email at your-subscribed-address

Please note: New list subscriptions now closed in preparation for transfer to OASIS.

More information about the Xml-dev mailing list