Ansicht
Dokumentation

ABENABAP_SXML_LIB_PARSE - ABAP SXML LIB PARSE

ABENABAP_SXML_LIB_PARSE - ABAP SXML LIB PARSE

SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.
SAP E-Book

- Parsing

XML data can be read using sXML Library or its syntax checked by being linked with an XML reader and using its methods. A reader like this is validating, meaning that invalid XML data raises an exception. It interprets the XML data as a hierarchical tree-like structure where each token is represented by a node assigned uniquely to a subnode (see W3C Information Set). An element with a literal value, for example, is interpreted as follows:

|
|--CO_NT_ELEMENT_OPEN
|    |
|    |--CO_NT_VALUE
|
|--CO_NT_ELEMENT_CLOSE

The value is a subnode of the node that represents the opening of an element. The names of the nodes here are the same as the constants of the interface IF_SXML_READER that describe the type of a node. The attributes of an element have a special task. They are assigned as a list to the node with the type CO_NT_ELEMENT_OPEN and can be accessed using special methods when the parser is on the opening of the element.

The classes and interfaces in sXML Library available for parsing XML data are organized so that there are separate XML reader classes for different requirements. These classes inherit from the abstract superclass CL_SXML_READER. The abstract superclass contains implementations of functions required by all readers and includes the interface IF_SXML_READER, which contains the components shared by all readers. This interface enables all readers to be accessed in the same way. If special components need to be accessed that are not declared in the interface, a downcast must be used on the corresponding class.

The specialized reader classes are:

Readers in this class parse XML data in a byte string.
Readers in this class parse XML data in an internal table with a flat byte-like line type.
Readers in this class parse XML data in a file on the host computer of the current .
Readers of this class parse XML data of an HTTP service in ICF.
Readers in this class parse XML data stored in XOP format.

The XML data to be parsed is passed to the factory method CREATE of each reader. Readers detect the format and the character format of the data themselves. Except for the XOP reader, readers support all formats except XOP. The XOP reader supports the XOP format only. Instructions on standardization and handling empty space can be passed to the factory method if the format is suitable.

The methods of the interface IF_SXML_READER enable serial parsing of the passed XML data. There are two basic ways to do this:

A reader cannot be used more than once for the same XML data or for other XML data. The read position of a reader is controlled during parsing using its methods. The actions allowed by a reader depend on its current read position. For example, a reader located at the end of the parsed XML data can no longer be used as an XML source of the statement CALL TRANSFORMATION. No method exists that can restore the reader to its initial state. A new reader can be created instead.

Notes

  • The parser of the sXML Library is a more strict validator than the parser of the iXML Library. A namespace prefix must be declared in the same element or in a superelement. Preceding declarations in a parallel element are interpreted as errors.
  • An XML reader in sXML Library can be specified as an XML source of the statement CALL TRANSFORMATION. This enables transformations to be performed for all sources supported by sXML readers in all supported formats. In particular, this makes it possible for JSON data to also be consumed directly in ABAP data objects.
  • The method SKIP_NODE, which can be used in both token-based and object-oriented parsing, offers various simple ways of checking the validity of a subtree or the entire tree or of copying a tree to a writer, whereby the format can be changed.
  • If the content of elements or attributes contain the notations <, >, &, ", or ', they are transformed automatically to the corresponding characters when parsed.

Transformation from XML Reader






Addresses (Business Address Services)   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.

Length: 7119 Date: 20240426 Time: 081840     sap01-206 ( 101 ms )