Get Example source ABAP code based on a different SAP table
ARTICLE
iXML> Library - Streams and Documents ITOC
Input Streams and Output Streams Input streams are used for the input of XML> data into the parser> and output streams are used to pass XML> data from the renderer>. A factory is needed to create a stream, which can be created using the iXML> factory as follows: DATA(ixml) = cl_ixml=>create( ). ... DATA(stream_factory) = ixml->create_stream_factory( ).> The static type of the reference variable stream_factory> is then the interface IF_IXML_STREAM_FACTORY> >, which contains factory methods CREATE_ISTREAM_...> for input streams and CREATE_OSTREAM_...> for output streams. Different streams can be created for different data sources and data sinks, such as strings, internal tables, or files specified by URI >.
Notes
iXML> input streams can be specified as an XML> source; iXML> outputs streams can be specified as an XML> target for XSL> transformations called using CALL TRANSFORMATION>>.
If output streams are bound to internal tables with byte-like row type, the last row is not usually filled completely with content from the stream. The length of the actual data in the row can be determined using the return value of the method GET_NUM_WRITTEN_RAW> of the output stream modulo the number of table rows.
Example The XML> result of a transformation of an ABAP data object to the asXML>> format is used to created an iXML> input stream. This stream is then transformed back again. CALL TRANSFORMATION id SOURCE text = `Hello XML!` RESULT XML DATA(xml_string).
DATA result type string. CALL TRANSFORMATION id SOURCE XML istream RESULT text = result.>
XML> Documents Each XML> saved in DOM> format in the memory is managed using a separate object. An object of this type can be created as follows: DATA(ixml) = cl_ixml=>create( ). ... DATA(document) = ixml->create_document( ).> The static type of the reference variable stream_factory> is also IF_IXML_DOCUMENT>. A document created in this way
is used to address an XML> document saved as DOM>>,
can be bound to the parser> to fill it,
can be used to construct new XML> data or modify existing data,
can be passed to the renderer> to produce the output of the renderer.
Note iXML> documents can be specified as an XML> target; iXML > documents and their nodes can be specified as an XML> source for XSL> transformations called using CALL TRANSFORMATION>>.
Example Creates a document and uses it as the XML> target of an XSL> transformation. The filled document is then passed to a renderer (to which an output stream for a character string is bound simultaneously) and rendered. The character string then contains the character-like representation of the XML> data. DATA(ixml) = cl_ixml=>create( ). DATA(document) = ixml->create_document( ).
CALL TRANSFORMATION id SOURCE text = `Hello XML!` RESULT XML document.
DATA xml_string TYPE string. ixml->create_renderer( document = document ostream = ixml->create_stream_factory( )->create_ostream_cstring( string = xml_string ) )->render( ).>