
Andreas, Andreas Pokorny <andreas.pokorny@gmx.de> writes:
Last time I had to process XML I wrote my own wrapper on top of SAX, which forwarded higher level events to xml-unaware structures. The model served well to directly map a fixed XML-format to C++ structures (also XML writing was supported). The wrapper that forwarded all SAX events to the datastructures was generated from a single C++ expression, or several if recursion was required. I adopted a lot of spirits techinques to make it look nice. There were no intermediate data structures.
In retrospective I also dislike my attempt, although it was better than working on xml document classes. It only worked with full xml documents, no partial parsing was supported. Furthermore it required a nearly direct mapping of xml elements to datastructures, different use cases which do not include a mapping of xml<->c++ werent considered.
We tried to solve this exact problem with the C++/Parser mapping for XML Schema. The basic idea boils down to generating parser templates for data types defined in XML Schema. Using these parser templates you can build your own in-memory representations or perform immediate processing of XML instance documents. The following document has a quick introduction to the mapping: http://codesynthesis.com/projects/xsd/documentation/cxx/parser/quick-guide/ hth, -boris