When to Use XML Streams
A common use for XML streams would be to persist state information about an application at shutdown and then restore that state when the application was next started.
By serializing the objects in XML format, the files on disk containing the serialization data are human readable. These files could potentially be read directly to access the data when the application was not running. XML is becoming widely used in distributed environments to transmit data between processes. With XML streams, processes can also pass objects or object references back and forth. This use is illustrated in
Figure 1. It is also the basis for the examples in the chapters of this book.
In many real world situations, the applications at either end of a distributed connection have different requirements for the form of the XML document being passed. For example, an XML document based on the purchase order format of one company might not correspond well to the purchase order format of the receiving company.
Such mismatches can be handled through a transformation of the XML stream. The XML Streams Module supplies classes to support several types of XML transformations. They are illustrated in the following chapters using detailed examples:
This example shows the basics of using XML streams to serialize out and read back in state information at application shutdown and restart.
This example shows how to use the “enhanced” streams, which impose fewer restrictions than the basic streams, and also result in XML output that is more natural-looking. These enhanced streams are also more suitable as the serializer/de-serializer for objects embedded in SOAP documents.
This example shows how to apply character-based and element-based C++ transformations to an input or output XML stream.
This example shows how to apply an XSLT transformation to an input or output XML stream.