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
For a Character-based C++ Transformation
{
RWObjectOutputStream out = //1
RWTTransformObjectOutputStreamImp<MyOutStreamTransform>
::make(cout,outTransform);
out << book2; //2
}
cout << endl;
{
RWObjectOutputStream out = //3
RWXmlObjectOutputStreamImp::make(cout);
out << book2; //4
}
return 0;
}
// 1 Sets up an XML output stream that includes support for a transformation.
// 2 Streams the transformed version of the book2 object to standard out.
// 3 Sets up an XML output stream with no transformation support.
// 4 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" 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>
Without transformation:
<?xml version="1.0" encoding="UTF-8" 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>
For an Element-based C++ Transformation
{
RWObjectOutputStream out = //1
RWTParsedObjectOutputStreamImp<MyOutParsedTransform>
::make(cout,outTransform);
out << book2; //2
}
cout << endl;
{
RWObjectOutputStream out = //3
RWXmlObjectOutputStreamImp::make(cout);
out << book2; //4
}
return 0;
}
// 1 Sets up an XML output stream that includes support for a transformation.
// 2 Streams the transformed version of the book2 object to standard out.
// 3 Sets up an XML output stream with no transformation support.
// 4 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" standalone="yes"?>
<book xmlns:rw="http://www.roguewave.com/xmlstream"
xsi:type="book"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<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" encoding="UTF-8" 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>