For an Element-based C++ Transformation
 
int main()
{
using std::ofstream; //1
using std::ifstream;
using std::cout;
using std::endl;
 
book book1("To Love and Be Wise","Josephine Tey"); //2
book book2;
 
MyInParsedTransform inTransform; //3
MyOutParsedTransform outTransform; //4
 
{
ofstream fout("book.xml"); //5
 
RWObjectOutputStream out = //6
RWTParsedObjectOutputStreamImp<MyOutParsedTransform>
::make(fout,outTransform);
out << book1; //7
out.flush(); //8
}
//1 Indicates that certain variables refer to their counterparts in the STD namespace.
//2 Creates two book objects, one with data, one to hold the data when you restore the object later on.
//3 Initializes the parsed transformation input stream. (For the full code example, see MyInParsedTransform.h and MyInParsedTransform.cpp at buildspace\examples\xmlstreams\transform\.)
//4 Initializes the parsed transformation output stream. (For the full code example, see MyOutParsedTransform.h and MyOutParsedTransform.cpp at buildspace\examples\xmlstreams\transform\.)
//5 Creates an ofstream for writing character data to a file.
//6 Sets up an XML output stream that includes support for a transformation.
//7 Serializes the book object to a file.
//8 Flushes the output buffer for the XML stream, transforming the XML in the process. You may perform this explicitly, as in this line, or you may let it happen implicitly when the destructor calls flush(), and the output stream goes out of scope.