Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Transformations for XML →  ST - Simple Transformations →  ST - Serialization and Deserialization →  ST - Transformation of ABAP Values →  ST - tt:value, Elementary Data Objects →  ST - option, Mapping Rules →  ST - option, Mapping Rules for XML Fragments 

Simple Transformation, Mapping of XML Fragments

The example demonstrates the mapping of XML fragments using ST.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    out = cl_demo_output=>new( ).

    DATA(xsdstr) = prepare_fragment( ).

    DATA(xmlstr1) = serialize(
      source = xsdstr
      trafo  = 'DEMO_ST_XSDANY'
      text =  'ST-Serialization of XML-Fragment' ).
    DATA(xmlstr2) = serialize(
      source = xsdstr
      trafo  = 'DEMO_ST_XSDANY_LAX'
      text =  'Lax ST-Serialization of XML-Fragment' ).
    DATA(xmlstr3) = serialize(
      source = xsdstr
      trafo  = 'DEMO_ST_XSDANY_NO_ROOT'
      text =  'noRoot-ST-Serialization of XML-Fragment' ).
    DATA(xmlstr4) = serialize(
      source = xsdstr
      trafo  = 'DEMO_ST_XSDANY_LAX_NO_ROOT'
      text =  'Lax noRoot-ST-Serialization of XML-Fragment' ).
    out->line( ).

    invoke_deserialization( source = xmlstr1
                            text   = `` ).
    invoke_deserialization( source = xmlstr2
                            text   = `lax ` ).
    invoke_deserialization( source = xmlstr3
                            text   = `noRoot-` ).
    invoke_deserialization( source = xmlstr4
                            text   = `lax noRoot-` ).

    out->display( ).

Description

The following transformations are called in this example:

  • DEMO_ST_XSDANY
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ROOT"/>
  <tt:template>
    <node>
      <tt:value ref="ROOT"/>
    </node>
  </tt:template>
</tt:transform>
  • DEMO_ST_XSDANY_LAX
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ROOT"/>
  <tt:template>
    <node tt:lax="on">
      <tt:value ref="ROOT"/>
    </node>
  </tt:template>
</tt:transform>
  • DEMO_ST_XSDANY_NO_ROOT
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ROOT"/>
  <tt:template>
    <node>
      <tt:value option="noRootAttr" ref="ROOT"/>
    </node>
  </tt:template>
</tt:transform>
  • DEMO_ST_XSDANY_LAX_NO_ROOT
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:root name="ROOT"/>
  <tt:template>
    <node tt:lax="on">
      <tt:value option="noRootAttr" ref="ROOT"/>
    </node>
  </tt:template>
</tt:transform>