SAP ABAP IXML LIB RENDER



Get Example source ABAP code based on a different SAP table
  



ABAP_IXML - Rendering
ITOC



Latest notes:

When data is rendered as character-like XML data, this data is prefixed with the byte order mark (BOM) that is required by the XML standard.
ABAP_HINT_END

Rendering a Full XML Document
An XML document in DOM representation is rendered using an XML renderer that can be created as follows using the iXML factory: DATA(ixml) = cl_ixml=>create( ).

...

DATA(renderer) = ixml->create_renderer(
ostream = ...
document = ... ).
The static type of the reference variable renderer is then the interface IF_IXML_RENDERER. A separate renderer is needed for each XML document. The renderer requires the following input parameters:
The output stream ostream that is the target of the rendering.
The XML document document to be rendered.
A renderer created in this way can be used to render the entire XML document as follows: renderer->render( ).
The rendered document is added to the data sink of the output stream.



Latest notes:

When the entire document is rendered, the data sink of the output stream should usually be initial beforehand. Otherwise, all the XML data is appended to existing content.
ABAP_HINT_END

Rendering Individual Nodes
The interface IF_IXML_NODE also contains a method RENDER that allows only parts of an XML document to be rendered: node->render( ostream = ...
recursive = abap_true|abap_false ).
The subtree is rendered whose initial node is pointed to by the reference variable node. recursive is used to specify whether the subnodes are respected or not. The rendered subtree is added to the data sink of the output stream.



Latest notes:

Using rendering of subtrees, XML data in the data sink of the output stream can be constructed from various parts.
There is no sequential rendering using events that would work in the same way as sequential parsing.
ABAP_HINT_END

ABAP_EXAMPLE_ABEXA
iXML Library - Render
ABAP_EXAMPLE_END

Token Renderers
Instead of using CREATE_RENDERER to create a renderer for an XML document in DOM representation, a token renderer can be created as follows: DATA(ixml) = cl_ixml=>create( ).

...

DATA(token_renderer) = ixml->create_token_renderer( ostream = ... ).
The static type of the reference variable token_renderer is then the interface IF_IXML_TOKEN_RENDERER . A token renderer only needs an output stream as an input parameter, but not an XML document in DOM representation. Instead, an internal table node_infos can be rendered as follows: token_renderer->render( node_infos ).
The table node_infos must have table type SIXMLDOM with line type SIXMLNODE and contain all required information for constructing XML data. Each line in the internal table describes a token of the XML data. The meaning of the columns is described by the enumeration type CO_NI_ of the interface IF_IXML_TOKEN_PARSER



Latest notes:

An input table for the method RENDERER of the interface IF_IXML_TOKEN_RENDERER can be created separately or be created from XML data using a token parser and modified later.
ABAP_HINT_END

ABAP_EXAMPLES_ABEXA
Token Parsers and Renderers, Iterative
Token Parsers and Renderers, Table.
ABAP_EXAMPLE_END