XML Binding Basics
The HydraExpress code generator maps an XML Schema into the C++ programming language, generating classes that contain the data represented by an XML Schema.
By default, HydraExpress implements an XML binding, providing default marshalling classes that marshal instances of the generated classes into XML documents that conform to the supplied schema, and unmarshal them back into class instance documents. While being marshaled and unmarshaled, the data may be XML or other formats that hold equivalent data.
An XML binding maps an XML Schema into a programming language (C++ in the case of HydraExpress), modeling an XML document in terms of the data the document contains rather than in terms of XML markup. An XML binding abstracts the structural details of XML. The binding handles the details of parsing XML input and creating XML output. Once the binding is created, code that uses classes created by HydraExpress needs no knowledge of XML.
HydraExpress generates the XML binding from a schema. A schema defines an XML document type. Instances of this document type must follow the structure laid out in the schema. For example, a schema for purchase orders describes the structure of a purchase order document. An XML document that conforms to a schema is an “instance document” of that schema. From the point of view of a data binding, the relationship between an instance document and a schema is similar to the relationship between a class definition and an instance of the class. Figure 1 illustrates this relationship:
Figure 1 – XML binding
The HydraExpress code generator creates classes that correspond to the definitions in the schema. The generated classes and the HydraExpress runtime library marshal objects into XML and unmarshal objects from XML.