iXML LibraryOther versions:
API of iXML Library
iXML Library provides an API for handling XML documents in DOM format. This API enables
- XML data to be parsed to DOM format,
- reads and writes to be performed on XML documents in DOM format (including creating new documents),
- XML documents in DOM format to be rendered to XML data.
In ABAP programs, the API is implemented using interfaces from the class library with the naming convention IF_IXML_.... The access class CL_IXML contains factory methods for creating objects such as streams, parsers, documents, and renderers. These objects are then accessed using interface reference variables. The classes and interfaces are documented in Class Builder.
- The classes and interfaces in iXML Library in package SIXML wrap classes and interfaces implemented in C++, delivered as part of the ABAP kernel.
- Standalone versions for C++ and C are also delivered, with the C version being a wrapper of the library implemented in C++.
- iXML Library supports the Unicode character format UCS-2. Characters from the surrogate area are not supported and can be rejected as invalid.
- DOM in iXML Library and its associated methods are also used internally in calls of
with the statement
Access to iXML Library
Precisely one factory object of the access class CL_IXML is required for accessing iXML Library in an ABAP program. This object is created as follows:
DATA(ixml) = cl_ixml=>create( ).
The static type of the reference variable
ixml is then the interface
IF_IXML, which contains all factory methods required to create further objects, such as streams, XML documents, parsers, or renderers. This factory object is a singleton and can only be instantiated once in one
Services in iXML Library
The most important services offered by the classes and interfaces in iXML Library are as follows:
- Complete Parsing to DOM
The parser creates the XML document in a DOM representation for the complete XML data in a single action and passes it to the memory.
- Sequential Parsing
The parser processes the input stream in sequential actions, where each sequence is determined by events that can be accessed using the interface IF_IXML_EVENT. The application can edit each sequence while the parser is running. It is possible to configure whether a full XML documented is saved to DOM representation.
- Parsing to Data Objects
When parsing to data objects, the tokens of the parsed XML data is written directly to ABAP data objects (structures, internal tables). An XML document in DOM representation can also be saved.
- One benefit of DOM is simple access to the individual parts of an XML document. It also has the drawback, however, of using more memory, up to ten times the actual size of the document. Note that the document itself can already use more memory for its markup than for the actual data. This memory use can be restricted by preventing a complete DOM from being created by sequential parsing or by parsing to data objects.
- The DOM in iXML Library also includes DTDs (Document Type Definitions).
- If XML data needs to be parsed and rendered only and no XML documents in DOM representation and no DTDs are needed, sXML Library provides an alternative with better performance than iXML Library.
- iXML only supports the XML 1.0 format, where, XML data is represented in a particular character format using a character string. sXML Library supports more formats.
- When data is rendered as character-like XML data, this data is prefixed in Unicode systems by the byte order mark (BOM) that is required by the XML standard.
- For examples, see the corresponding programs in the example library and the package SIXML_TEST.