ABAP Keyword Documentation → ABAP - Reference → Data Interfaces and Communication Interfaces → ABAP and XML → asXML - Canonical XML Representation → asXML, Examples of Mappings
asXML, Mapping of Qualified Names
The example demonstrates the mapping of XML schema data types for qualified names.
Other versions: 7.31 | 7.40 | 7.54
Source Code
DATA: name1 TYPE string,
name2 TYPE string,
qname1 TYPE xsdqname,
qname2 TYPE xsdqname.
DATA xmlstring TYPE string.
name1 = qname1 = '{test_uri}Value1'.
name2 = qname2 = '{test_uri}Value2'.
CALL TRANSFORMATION id SOURCE test1 = name1
test2 = name2
RESULT XML xmlstring.
cl_abap_browser=>show_xml(
xml_string = xmlstring
title = 'Serialization of Strings' ).
CALL TRANSFORMATION id SOURCE test1 = qname1
test2 = qname2
RESULT XML xmlstring.
cl_abap_browser=>show_xml(
xml_string = xmlstring
title = 'Serialization of XSDQNAME' ).
xmlstring =
`<?xml version="1.0" encoding="utf-8" ?>` &&
`<asx:abap ` &&
`xmlns:asx="http://www.sap.com/abapxml" ` &&
`xmlns:demox="my_uri" version="1.0">` &&
`<asx:values >` &&
`<TEST1>demox:Value1</TEST1>` &&
`<TEST2>Value2</TEST2>` &&
`</asx:values>` &&
`</asx:abap>`.
cl_abap_browser=>show_xml(
xml_string = xmlstring
title = 'Source for Deserialization' ).
CALL TRANSFORMATION id SOURCE XML xmlstring
RESULT test1 = name1
test2 = name2.
CALL TRANSFORMATION id SOURCE XML xmlstring
RESULT test1 = qname1
test2 = qname2.
SKIP.
WRITE: /(20) name1, (20) name2.
SKIP.
WRITE: /(20) qname1, (20) qname2.
Description
First of all, only two serializations of ABAP data objects are carried out in the asXML format. Their
content corresponds to the "{URI}name" format. For the first serialization, the data objects are of
the type string
, for the second they are of the type XSDQNAME. Whilst in
the first case the content is transferred unchanged, in the second case it is interpreted as a qualified name and the corresponding namespace declarations are created.
Next, an XML file, which contains an element with a namespace prefix and one without a namespace prefix,
is created. This file is deserialized in ABAP data objects of the type string
and XSDQNAME. The element with a namespace prefix is deserialized in the data object of the type
string without being changed. However, when deserializing in the data object of the type XSDQNAME,
a conversion to the format "{URI}name" takes place. The element with no namespace prefix is deserialized without being changed in both cases, since there is only the empty standard namespace.