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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: nestable C/C++ XML parser?

[ Lists Home | Date Index | Thread Index ]
  • From: Steinar Bang <sb@metis.no>
  • To: xml-dev@ic.ac.uk
  • Date: 08 Dec 1999 15:19:21 +0100

>>>>> Paul Miller <stele@fxtech.com>:

> ... 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@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