Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Transformations for XML →  asXML - Canonical XML Representation →  asXML, Examples of Mappings 

asXML, Transformation ID vs. Simple Transformation

This example demonstrates the differences between the transformation ID and a Simple Transformation.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    DATA: str TYPE string,
          xml TYPE string,
          len TYPE i.

    DATA(out) = cl_demo_output=>new(
      )->begin_section( 'XSLT ID' ).
    str = `     `.
    len = strlen( str ).
    out->write_text( |String length before: { len }| ).
    CALL TRANSFORMATION id SOURCE node = str
                           RESULT XML xml.
    out->write_xml( xml ).
    CALL TRANSFORMATION id SOURCE XML xml
                           RESULT node = str.
    len = strlen( str ).
    out->write_text( |String length after: { len }| ).

    out->next_section( 'ST tt:copy' ).
    str = `     `.
    len = strlen( str ).
    out->write_text( |String length before: { len }| ).
    CALL TRANSFORMATION demo_asxml_copy SOURCE root = str
                                       RESULT XML xml.
    out->write_xml( xml ).
    CALL TRANSFORMATION demo_asxml_copy SOURCE XML xml
                                       RESULT root = str.
    len = strlen( str ).
    out->write_text( |String length after: { len }|
      )->display( ).

Description

A text string with five blanks is serialized and deserialized to a Simple Transformation DEMO_ASXML_COPY using the predefined identity transformation ID and the statement tt:copy. The transformation ID contains the statement <xsl:strip-space elements="*"/> , which means that the blanks are ignored by the deserialization and the text string then has the length 0. After the deserialization by the Simple Transformation, the blanks are present in the text string.