Get Example source ABAP code based on a different SAP table
VERSION 5 IN • CL_SXML_STRING_WRITER ABAP_CLASS • CL_SXML_TABLE_WRITER ABAP_CLASS BEGIN_SECTION VERSION 5 OUT • CL_SXML_DATASET_WRITER ABAP_CLASS • CL_SXML_HTTP_WRITER ABAP_CLASS • CL_SXML_XOP_WRITER ABAP_CLASS END_SECTION VERSION 5 OUT
ABAP_SXML - Rendering To create XML data using sXML Library, the content is passed to an XML writer. A writer of this 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 that can be assigned uniquely to a parent node (see W3C Information Set>). An XML writer can be used to write the data in exactly the same way is read by an XML reader>. The classes and interfaces> of the sXML Library that are 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 downcast must be used on the corresponding class. 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 line type. BEGIN_SECTION VERSION 5 OUT
CL_SXML_DATASET_WRITER>> Writers in this class render XML data to a file on the host computer> of the current ABAP_ASINSTANCE .
CL_SXML_HTTP_WRITER>> Writers in this class render XML data to an ICF> HTTP client.
CL_SXML_XOP_WRITER>> Writers of this class render the data to XOP> format. END_SECTION VERSION 5 OUT Each of these classes has a specific factory method CREATE> for creating appropriate writers. Apart from an XOP writer, the required format> and the required character format of the data can be passed to each writer. The standard format is XML 1.0 format in the UTF-8 character format. BEGIN_SECTION VERSION 5 OUT The XOP writer supports the XOP format only. END_SECTION VERSION 5 OUT Instructions on standardization and handling empty elements can be passed to the factory method if the format is suitable. 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 write position of a writer is updated during rendering using its methods. The actions allowed by a writer depend on the current write position. For writers that do not write to external repositories, the written XML can be read using the method GET_OUTPUT>.
Latest notes:
In a suitable write position, an XML writer from the sXML Library can 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 write position moved accordingly.
The writers in the 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>. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_ABEXA Transformation to XML Writers> ABAP_EXAMPLE_END