SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Class Libraries for XML → sXML Library → sXML Library - Render →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:
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:
Once the writer is created, nodes can be written. The order of the nodes is important, for example:
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:
Since the method is a class-specific method, a down cast is required if an interface reference variable is being used.
Example
Methods for Token-Based Rendering
The following methods are declared in the interface IF_SXML_WRITER for token-based rendering:
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.