Show TOC

Syntax documentationSkipping XML Elements During Deserialization Locate this document in the navigation structure

The following command allows you to skip XML elements during deserialization.

<tt:skip [name=""] [count="name"]/>cnt

The tt:skip command can be positioned anywhere within a template.

Serialization

During serialization, tt:skip has no effect.

Deserialization

During deserialization, tt:skip has the following effect:

  • Without additions, the following XML content of the inbound stream is consumed up to the end of the current element or non-literal attribute, but no other ST commands are executed.

  • With the name attribute and the count attribute, as many consecutive elements of the name name are not deserialized as specified by a number cnt.

  • With the name attribute and without the count attribute, or with the count="*" attribute, any number of consecutive elements of the name name are not deserialized.

  • Without the name attribute and with the count attribute, as many consecutive elements after the current element are not deserialized as specified in cnt. For cnt, you can specify a number or *, where * stands for any number of elements.

During deserialization, when comparing the template, the tt:skip command is compared to the structure of the inbound stream as if the skipped elements were specified in its place. This means that a tt:skip command with the name attribute is correct only if this position of the XML inbound stream also has the corresponding number of elements of the specified name, and the element of a template executed after a tt:skip command must correspond to the element in the XML document that follows after the skipped elements.

Example

In the Simple Transformation below, the template is divided into a part for serialization and a part for deserialization. During deserialization, the first two X1 elements, all X2 elements after the first X2 element, and the Y element including all its subelements are skipped.

Syntax Syntax

  1. <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  2.   <tt:root name="ROOT"/>
  3.   <tt:template>
  4.       <struc tt:ref="ROOT">
  5.       <tt:serialize>
  6.           <X1><tt:value ref="COL0" /></X1>
  7.           <X1><tt:value ref="COL1" /></X1>
  8.           <X1><tt:value ref="COL2" /></X1>
  9.           <X2><tt:value ref="COL3" /></X2>
  10.           <X2><tt:value ref="COL4" /></X2>
  11.           <X2><tt:value ref="COL5" /></X2>
  12.           <Y>
  13.             <X3><tt:value ref="COL6" /></X3>
  14.             <X3><tt:value ref="COL7" /></X3>
  15.             <X3><tt:value ref="COL8" /></X3>
  16.           </Y>
  17.           <X4><tt:value ref="COL9" /></X4>
  18.       </tt:serialize>
  19.       <tt:deserialize>
  20.         <tt:skip name="X1" count="2" />
  21.         <X1><tt:value ref="COMPA" /></X1>
  22.         <X2><tt:value ref="COMPB" /></X2>
  23.         <tt:skip name="X2" count="*" />
  24.         <tt:skip name="Y" count="1" />
  25.         <X4><tt:value ref="COMPC" /></X4>
  26.         <tt:skip />
  27.       </tt:deserialize>
  28.     </struc>
  29.   </tt:template>
  30. </tt:transform>
End of the code.

The following ABAP program can call the transformation:

Syntax Syntax

  1. DATA xml_string TYPE string.
  2. DATA: BEGIN OF struc,
  3.         col0 TYPE i VALUE 0,
  4.         col1 TYPE i VALUE 1,
  5.         col2 TYPE i VALUE 2,
  6.         col3 TYPE i VALUE 3,
  7.         col4 TYPE i VALUE 4,
  8.         col5 TYPE i VALUE 5,
  9.         col6 TYPE i VALUE 6,
  10.         col7 TYPE i VALUE 7,
  11.         col8 TYPE i VALUE 8,
  12.         col9 TYPE i VALUE 9,
  13.       END OF struc.
  14. DATA: BEGIN OF result,
  15.         compa TYPE i,
  16.         compb TYPE i,
  17.         compc TYPE i,
  18.       END OF result.
  19. CALL TRANSFORMATION ...
  20.   SOURCE root = struc
  21.   RESULT XML xml_string.
  22. CALL TRANSFORMATION ...
  23.   SOURCE XML xml_string
  24.   RESULT root = result.
End of the code.

After the deserialization, the components of result receive the values of the third, fourth, and tenth component of struc.