Examining the XML Output
Finally, the example writes to standard out two forms of the serialized object:
*the transformed, more readable version
*the form created by the XML serialization and expected by XML streams when the object is restored
 
{
ifstream script("../XmlStreamOut.xsl"); //1
RWObjectOutputStream out = //2
RWXsltObjectOutputStreamImp::make(cout,script);
out << book2; //3
}
cout << endl;
{
RWObjectOutputStream out = //4
RWXmlObjectOutputStreamImp::make(cout);
out << book2; //5
}
return 0;
}
//1 Creates an ifstream for reading in the output XSLT stylesheet.
//2 Sets up an XML output stream that includes support for a transformation by passing the ifstream to the output XSLT stylesheet.
//3 Streams the transformed version of the book2 object to standard out.
//4 Sets up an XML output stream with no transformation support.
//5 Streams the standard XML streams version of the book2 object to standard out.
Here is the resulting output:
With transformation:
<?xml version="1.0" encoding="UTF-8"?>
<book xmlns:rw="http://www.roguewave.com/xmlstream"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:type="book">
<title xsi:type="xsd:string">To Love and Be Wise</title>
<author xsi:type="xsd:string">Josephine Tey</author>
</book>
 
Without transformation:
<?xml version="1.0" standalone="yes"?>
<rw:nested_object rw:class="book"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:rw="http://www.roguewave.com/xmlstream">
<rw:member rw:name="title" xsi:type="xsd:string">To Love and Be
Wise</rw:member>
<rw:member rw:name="author" xsi:type="xsd:string">Josephine
Tey</rw:member>
</rw:nested_object>