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

Re: nestable C/C++ XML parser?

  • From: Steinar Bang <sb@m...>
  • To: xml-dev@i...
  • Date: 08 Dec 1999 15:19:21 +0100

c xml parser class
>>>>> Paul Miller <stele@f...>:

> ... I want to use XML as an application data file format. Why? Two
> primary reasons:
> 1. I don't need/want to invent a new syntax - I like XML just fine and
> it handles object-oriented nesting of data quite nicely
> 2. I can publish a DTD and make it easier for my end-users to use my
> application data in their own applications 
[snip!]

I have a similar situation, but went for a very different solution:
 1. wrapped a SAXoid interface around expat
 2. wrote a callback class with virtual functions for all
    elements in the DTD
 3. wrote a DocumentHandler that contains a pointer to an instance of
    the callback class, and a table of tag names and pointers to
    member functions of the callback class.  This class also
    does some rudimentary element content checking, but this will be
    dropped when a validating parser is available

Then I have two implementations of the callback class:
 - a simple one for debugging of the expat/sax chain, that just prints 
   out what it receives
 - a complicated one that unpacks attributes, keeps context between
   SAX events on a stack, and builds data structures in the system

The gain here is that since I'm relying on SAX (and plan to track the
standard that David Megginson and James Clark et al. settle on) I will
in the future have a choice of parsers, and can use one that supports
namespaces and/or validation.

It also lets me have the same basic infrastructure for all XML based
formats (I currently have two: our native format and SVG).

The biggest and clumsiest code here, is the recognition and decoding
of element attributes in the callback class.

Good guidelines for efficiency and simplicity are highly desired.

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-2011 All Rights Reserved.