sapdev logo background
sapdev logo sapdev logo
Comments

SAP ABAP SXML LIB RENDER TOKEN documentation, setup help and example usage



Return to SAP documentation index


ARTICLE

sXML Library - Token-Based Rendering
In token-based rendering, each node is written to the XML data by a method. Each node type has its own method. If a node can have specific values, the method in question has appropriate input parameters. The methods must be called in such a way that valid XML is created. XML attributes can be added to an element directly after it has been opened.

Procedure (Principles)
An XML writer is created using the factory method CREATE of the class in question. The format and character format can also be defined, for example:
DATA(writer) = cl_sxml_string_writer=>create( type =
encoding = ... ).
Here, the static type of the reference variables is the type of the class itself, since more class-specific methods exist than in readers. The interface IF_SXML_WRITER can still be used to access a writer by using up casts:
DATA(writer) = CAST if_sxml_writer( cl_sxml_string_writer=>create( ... ) ).
Once the writer is created, nodes can be written. The order of the nodes is important, for example:
writer->open_element( ... ).
writer->write_attribute( ... ).
writer->write_value( ... ).
writer- close_element( ).
Once a complete valid record of XML data has been written, the data can be read (if the correct writers are being used), for example:
DATA(xml) = CAST cl_sxml_string_writer( writer )- get_output( ).
Since the method is a class-specific method, a down cast is required if an interface reference variable is being used.

Example
See Token-Based Rendering .

Methods for Token-Based Rendering
The following methods are declared in the interface IF_SXML_WRITER for token-based rendering:
  • OPEN_ELEMENT - Writes an opened element. The name, a namespace prefix, and a namespace URI can be passed.

  • WRITE_NAMESPACE_DECLARATION - Writes a namespace declaration to an opened element.

  • WRITE_ATTRIBUTE - Writes an XML attribute to an opened element. A name, namespace prefix, a namespace URI , and a character-like value can be passed.

  • WRITE_ATTRIBUTE_RAW - Writes an XML attribute with raw data to an opened element. A name, namespace prefix, a namespace URI

  • , and a byte-like value can be passed.
  • WRITE_VALUE - Writes a character-like value behind an opened element.

  • WRITE_VALUE_RAW - Writes a byte-like value behind an opened element.

  • CLOSE_ELEMENT - Writes a closed element.

  • If text-like data is written, this data is converted automatically from the current system code page to the representation of the XML , which is determined by the chosen format
    . If byte-like raw data is written, this data is also converted in accordance with the chosen format , for example to the format Base64 for
    XML 1.0 or to the binary part of the XOP package for XOP .

    Example
    See Namespace Declarations in Token-Based Rendering .
    Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




    ABAP_SXML_LIB_RENDER_OO
    ABAP_SXML_LIB_VALUES




    comments powered by Disqus