ARTIClE
asXML , Mapping of XML Fragments
The example demonstrates the mapping of XML fragments.
ABAP_SOURCE_CODE
ABAP_EXEC
ABAP_DESCRIPTION
This example demonstrates the serialization and deserialization of
XML fragments and their representation in asXML using the
identity transformation ID .
First, an XML fragment with the root element X is created
in a variable xstr with the type xstring and the result
displayed.
The fragment is serialized from the variable xstr of type
xstring to an element ROOT in accordance with the rules for
the mapping of elementary data types
. The XML schema type xsd:base64Binary is used as a
format.
On the other hand, a serialization of the fragment from the variable
xsdstr of type XSDANY adds the attribute asx:root
with the content "X" (that is, the name of the root element of
the XML fragment) to the element ROOT and represents the
remaining content of the fragment without modification.
A further serialization of the fragment from the variable xsdstr
produces the element X . This has the same name as the root
element of the XML fragment and so the attribute is not added.
Any attempt to deserialize the fragment content to an ABAP variable of
type xstring fails for both serialization results, since the
attribute specified for NODE when mapping elementary data types
is not supported or because no valid asXML format exists for the
target variable.
Deserializations to variables of type XSDANY are possible in both
cases, however, and produce the original XML fragment again in
the variable.
If a nonexistent element is addressed in deserializations, no
deserialization is performed (as usual).
For information about serializations and deserializations of XML
fragments using simple transformations , see
ST , Mapping of XML Fragments .
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved