XSD/e: XML Processing for Embedded Systems
CodeSynthesis XSD/e is an open-source XML parser/serializer generator for mobile and embedded systems. It provides event-driven, stream-oriented XML parsing, XML serialization, XML Schema validation, and C++ data binding while maintaining a small footprint and portability.
XSD/e provides two XML Schema to C++ mappings: Embedded C++/Parser for XML parsing and Embedded C++/Serializer for XML serialization. The C++/Parser mapping generates validating C++ parser skeletons for data types defined in XML Schema. You can then implement these parser skeletons to build your own in-memory representation or perform immediate processing as parts of your XML documents become available. For an introduction to the C++/Parser mapping, refer to the Hello World Example from the Embedded C++/Parser Mapping Getting Started Guide.
Similarly, the Embedded C++/Serializer mapping generates validating C++ serializer skeletons for types defined in XML Schema which can be used to serialize your data to XML. For an introduction to the C++/Serializer mapping, refer to the Hello World Example from the Embedded C++/Serializer Mapping Getting Started Guide.
Based on the static analysis of the schemas, 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. The following figure highlights the advantages of XSD/e in comparison to the traditional architectures:
XSD/e is also highly-portable and can be used without STL, RTTI, iostream, C++ exceptions, and C++ templates. Compared to APIs such as SAX, XMLReader, and XMLWriter, XSD/e-generated code has the following advantages:
- Ease of use. The generated skeletons maintain state and do data conversion for you. As a result, you are shielded from the intricacies of parsing and serializing XML.
- Validation. The generated code provides low-footprint, high-performance XML Schema validation so you don't need to complicate your code with extra error checking.
- Natural representation. Works with the XML data using your domain vocabulary instead of generic elements, attributes, and text.
- Static typing. The generated skeletons are statically typed which helps catch errors at compile-time rather than at run-time. For example, XML element and attribute names become C++ function names so if you misspell one, the compiler will let you know.
- Concise code. Thanks to the object representation provided by the skeletons, your business logic implementation is simpler and thus easier to read and understand.
- Maintainability. Automatic code generation minimizes the effort needed to adapt your application to changes in the document structure. Thanks to static typing, the C++ compiler will pin-point the places in your code that need to be changed.
These technical advantages translate to the following business benefits:
- Faster time to market. Instead of having your engineers spend months or years on the boiler plate code, let them concentrate on what makes your product unique—the business logic.
- Minimize risks. The generated code is more reliable and has fewer bugs thanks to the repeated and widespread use. Reduction in the amount and simplification of the business logic code your engineers have to write by hand further reduces the risks.
- Reduce costs. Automatic code generation is significantly cheaper than manual development. Furthermore, simplified business logic implementation means lower maintenance and development costs.