Element-based Transformations
An element-based transformation stream differs from a character-based transformation stream in that the XML document is parsed by the stream before being handed to the transformation object.
The transformation stream passes to the transformation object a pointer to the root element of the document (See the RWXmlStreamElement in the SourcePro API Reference Guide for a description of the internal structure used to represent an XML element.). The transformation object is then free to modify the document in any way. A transformation object may alter element names or attributes, or may restructure the document by adding, deleting, or rearranging elements contained by the root element or sub-elements.
An element-based transformation is much easier to implement, since the transformation stream handles all the parsing and serialization logic. As long as the initial input or final output to or from an XML stream is all XML, this kind of transformation is more suitable than a character-based transformation.
An element-based transformation cannot be used to transform XML to a non-XML document, or a non-XML document to XML, since the interface to the transformation object is an internal XML structure.
This chapter includes code examples from the file parsedTransform.cpp. For the complete example, see buildspace\examples\xmlstreams\transform\parsedTransform.cpp.