sapdev logo background
sapdev logo sapdev logo
Comments

SAP ABAP IXML LIB RENDER documentation, setup help and example usage



Return to SAP documentation index


ARTICLE

iXML Library - Render

Rendering a Full XML Document
An XML document in DOM representation is rendered using an
XML renderer, 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

  • that is rendered.
    A renderer created in this way can be used to render the full XML
    document as follows:
    renderer- render( ).
    The rendered document is added to the data sink of the output stream.

    Note
    When the full document is rendered, the data sink of the output stream should usually be initial at the start. Otherwise, all the XML data is appended to existing content.

    Rendering Individual Nodes
    The interface IF_IXML_NODE also contains a method, RENDER , that permits 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.

    Notes
  • Using rendering of subtrees, XML in the data sink of the output stream can be constructed from various parts.

  • Sequential rendering using events (as in sequential parsing ) is not available.


  • Example
    See iXML Library, Render

    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 row type SIXMLNODE and contain all required information for constructing XML data. Each row in the internal table describes a token of the XML data. The meaning of the columns is described using the counter type CO_NI_ of the interface IF_IXML_TOKEN_PARSER

    Note
    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.

    Example
    See
  • Token Parsers and Renderers, Iterative

  • Token Parsers and Renderers, Table .
    Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




  • ABAP_IXML_LIB_PARSE_TOKEN
    ABAP_IXML_LIB_RENDERER




    comments powered by Disqus