XSD/e: XML for Light-Weight C++ Applications

CodeSynthesis XSD/e is an open-source, dependency-free XML Schema to C++ compiler for mobile, embedded, and light-weight applications. It provides XML parsing, serialization, XML Schema validation and XML data binding while maintaining a small footprint and portability.

Provided with a schema, XSD/e generates C++ classes that represent the given XML vocabulary as well as parsing and serialization code. You can then access the data stored in XML using types and functions that semantically correspond to your application domain rather than dealing with the intricacies of reading and writing XML:

object* obj = ...; // Parse XML.
const char* name = obj->name ();
position& pos = obj->position ();
float lat = pos.lat ();
float lon = pos.lon ();

delete obj;
<object>
    <name>Red Hill</name>
    <position>
      <lat>-33.69</lat>
      <lon>18.83</lon>
    </position>
</object>

Manually handling XML in mobile and embedded applications with low-level APIs such as SAX and DOM traditionally leads to increased complexity, poor performance, and a large footprint. With XSD/e you can have all the benefits of using XML without any of the drawbacks. Your application stays small and fast and the code you write will be enjoyable to work with. XSD/e has been successfully used in the following mobile and embedded application domains:

XSD/e supports several distinct methods, called mappings, for manipulating the data stored in XML. The C++/Hybrid mapping creates a light-weight, tree-like object model of the XML data as shown in the code fragment above. Alternatively, you can forego the in-memory representation and process the data as it becomes available using the lower-level C++/Parser (for XML parsing) and C++/Serializer (for XML serialization) mappings. The C++/Hybrid mapping also supports the hybrid, partially in-memory, partially event-driven processing model which allows you to load/save XML documents a small fragment at a time. In addition to XML, you can serialize the object model into a number of compact binary formats, for example, for storage or over-the-wire transfer.

Based on the static analysis of the schema, XSD/e generates compact, highly-optimized hierarchical state machines that combine data conversion, validation, and even dispatching in a single step. As a result, the XSD/e-generated code is 2-10 times faster than general-purpose XML Schema validators while maintaining the lowest static and dynamic memory footprints. For example, a validating parser executable can be as small as 120KB in size and process a 10MB/s XML stream.

XSD/e is also highly-portable and can be configured to use the C++ feature set ranging from modern C++ to highly-restricted embedded C++. In particular, you can individually enable or disable the use of STL, RTTI, iostream, C++ exceptions, and custom memory allocators.

The following figure and feature list highlight the advantages of XSD/e in comparison to the traditional XML processing architectures:

XSD/e Architecture

These technical advantages translate to the following business-level benefits: