SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Transformations for XML → CALL TRANSFORMATION → CALL TRANSFORMATION - Examples →Transformation of XML Syntax Characters
This example demonstrates the serialization of characters from the XML syntax using various transformations.
Source Code
REPORT demo_transformation_escaping.
CLASS demo DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
ENDCLASS.
CLASS demo IMPLEMENTATION.
METHOD main.
DATA xml TYPE string.
DATA(text) = `<>&"`.
DATA(out) = cl_demo_output=>new(
)->begin_section( `Text`
)->write( text
)->next_section( `XSLT`
)->begin_section( `<xsl:output method="text" />` ).
CALL TRANSFORMATION demo_escaping_text SOURCE text = text
RESULT XML xml.
out->write( xml
)->next_section( `<xsl:output method="xml" />` ).
CALL TRANSFORMATION demo_escaping_xml SOURCE text = text
RESULT XML xml.
out->write( xml
)->next_section( `<xsl:output method="html" />` ).
CALL TRANSFORMATION demo_escaping_html SOURCE text = text
RESULT XML xml.
out->write( xml
)->next_section( `<xsl:output method="html" />` ).
CALL TRANSFORMATION demo_escaping_js SOURCE text = text
RESULT XML xml.
out->write( xml
)->end_section(
)->next_section( `ST` ).
CALL TRANSFORMATION demo_escaping_st SOURCE text = text
RESULT XML xml.
out->write( xml ).
out->display( ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo=>main( ).
Description
Four XSLT programs with different output methods are called and an ST program for serializing a text string containing the syntax characters <>&". The results are as follows:
The results of the simple transformation DEMO_ESCAPING_ST match the XSL transformation with the output method "xml". Also, the text string is displayed here as an attribute in which the syntax character " is replaced by ".