SAP ABAP SXML LIB RENDER

Get Example source ABAP code based on a different SAP table
  


ARTICLE

sXML Library - Render
To create XML data using sXML Library, the content is passed to a XML writer. A writer of the type is 'validating', which means that invalid actions, such as attempts to add an attribute to a value node, raise an exception. An XML writer creates the XML data as a hierarchical tree-like structure where each token is represented by a node assigned uniquely to a subnode (see W3C Information Set). An XML writer can be used to write the data in precisely the same way is read by an XML reader.
The classes and interfaces in sXML Library available for rendering XML data are organized so that there are separate XML writer classes for different requirements. These classes inherit from the abstract superclass CL_SXML_WRITER. The abstract superclass contains implementations of functions required by all writers and includes the interface IF_SXML_WRITER , which contains the components shared by all writers. This interface enables all writers to be accessed in the same way. If special components need to be accessed that are not declared in the interface, a down cast must be used on the class in question.
The specialized writer classes are:
CL_SXML_STRING_WRITER Writers in this class render XML data to a byte string.
CL_SXML_TABLE_WRITER Writers in this class render XML data to an internal table with a flat byte-like row type.
CL_SXML_DATASET_WRITER Writers in this class render XML data to a file on the application server.
CL_SXML_HTTP_WRITER Writers of this class render XML data to a HTTP client in ICF.
CL_SXML_XOP_WRITER Writers of this class render the data to XOP format.
Each of these classes has a specific factory method, CREATE, for creating appropriate writers. As well as an XOP writer, the required format and the required character format of the data can be passed to each writer. The standard is XML 1.0 format in the UTF-8 character format. The XOP writer supports only the XOP format. Instructions on standardization and handling empty elements can be passed to the factory method if permitted by the format.
The methods of the interface IF_SXML_WRITER enable serial rendering of XML data. There are two basic ways to do this:
Token-based rendering
Object-oriented rendering
A writer cannot be used more than once for the same XML data or for other data. The writer position of a writer is updated while rendering using its methods. The actions permitted by a writer are specified by its current writer position. For writers that do not write to external repositories, the written XML can be read using the method GET_OUTPUT.

Notes
An XML writer in sXML Library can, if the writer position is suitable, be used as an XML target of the statement CALL TRANSFORMATION. The output of the transformation is inserted into the output of the writer and its writer position moved accordingly.
The writers in sXML Library do not currently support XML comments, CDATA, sections, or processor instructions.
If rendering produces content of elements or attributes, the characters <(><<)>, >, <(> <)>, ', and ' are transformed automatically into the associated XML notation.

Example
Transformation to XML Writer