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 - Formats
The formats supported by sXML Library are represented by the constants of the interface IF_SXML:
- XML 1.0 (constant IF_SXML=>CO_XT_XML10)
-
Standard XML in accordance with W3C.
XML data is represented in a specific character format using a character string (standard is Unicode character format UTF-8). Raw data whose binary content is to be saved is portrayed using
Base64 representation.
- XOP (constant IF_SXML=>CO_XT_XOP)
-
XML-binary Optimized Packaging in accordance with
W3C. All data other than raw data is represented as a character string, as in XML 1.0. Raw data is not represented as part of the character string in
Base64 format. Instead, elements
xop:Include (namespace http://www.w3.org/2004/08/xop/include)
are inserted in its place, which contain references to the raw data. The raw data itself is extracted
unchanged and saved in byte strings. The string with the character string and the byte strings with
the raw data are combined in a package whose parts can be edited together. In sXML Library, a package
of this type is described using the structured type IF_SXML_XOP=>XOP_PACKAGE, whose first component
XOP_DOCUMENT has the type string for the character string. The second component
PARTS is a hashed table for the byte strings. The key column CONTENT_ID is the reference target for
the references in the xop:Include elements. The column BINARY_DATA has the type xstring and the raw data is passed to this column.
- Binary XML (constant IF_SXML=>CO_XT_BINARY)
-
SAP-specific binary format for XML data. It suppresses redundant information. The XML data is not represented
as globally readable character strings and the only character set allowed is UTF-8. Special XML readers and XML writers that understand the format are needed to parse and render XML data to
Binary XML. sXML can be used to create these objects.
- JSON (constant IF_SXML=>CO_XT_JSON)
-
JavaScript Object Notation in accordance with json.org.
JSON is not XML but JSON data can be represented using XML data. Once mapping of this type is the SAP-specific
JSON-XML. The format JSON
in sXML Library indicates that an XML writer of this format transforms valid JSON-XML data to JSON data and an XML reader detects JSON data and parses it as if it were JSON-XML data. All methods for
handling JSON in ABAP are based on readers and writers like these.
When an XML writer is created, the format created by the writer is defined as follows:
- For all formats except XOP, the factory methods CREATE of the various writers have an input parameter
TYPE to which the value of the constants above can be passed. The XML 1.0 format is used by default.
The character format can be passed to the input parameter ENCODING. The default value is UTF-8. Writers Binary XML only accept the default.
- Only the special class CL_SXML_XOP_WRITER can be used for the XOP format. The factory method CREATE
of this class does not need an input parameter. XOP writers always return data objects with the type IF_SXML_XOP=>XOP_PACKAGE.
When an XML reader is created, it detects the
format of the data passed to the parameter INPUT of the factory method CREATE. The same reader classes
can be used for all formats except XOP. Only the special class CL_SXML_XOP_READER can be used for the XOP format. The factory method CREATE of this class expects an actual parameter of the type IF_SXML_XOP=>XOP_PACKAGE.
Notes
- The attribute TYPE declared in the interface IF_SXML contains the type
of every XML reader and XML writer or the format it is editing. The possible values of the attribute are the same as those of the constants CO_XT_... of the interface.
- XML readers and XML writers of a particular XML format can be used to transform this format to a another format.
Examples
See XML Formats and Transformation of Formats.