The following command allows you to skip XML elements during deserialization.
<tt:skip [name="name"] [count="cnt"]/>
The tt:skip command can be positioned anywhere within a template.
During serialization, tt:skip has no effect.
During deserialization, tt:skip has the following effect.
During deserialization, when comparing the template, the tt:skip command is compared to the structure of the inbound stream as if in its place the skipped elements were specified. This means that a tt:skip command with the attribute name is correct only if at this position of the XML inbound stream the corresponding number of elements of the specified name exist; 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.
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.
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:template>
<struc
tt:ref="ROOT">
<tt:serialize>
<X1><tt:value ref="COL0" /></X1>
<X1><tt:value ref="COL1" /></X1>
<X1><tt:value ref="COL2" /></X1>
<X2><tt:value ref="COL3" /></X2>
<X2><tt:value ref="COL4" /></X2>
<X2><tt:value ref="COL5" /></X2>
<Y>
<X3><tt:value ref="COL6" /></X3>
<X3><tt:value ref="COL7" /></X3>
<X3><tt:value ref="COL8" /></X3>
</Y>
<X4><tt:value ref="COL9"
/></X4>
</tt:serialize>
<tt:deserialize>
<tt:skip name="X1" count="2" />
<X1><tt:value ref="COMPA" /></X1>
<X2><tt:value ref="COMPB" /></X2>
<tt:skip name="X2" count="*" />
<tt:skip name="Y" count="1" />
<X4><tt:value ref="COMPC" /></X4>
<tt:skip />
</tt:deserialize>
</struc>
</tt:template>
</tt:transform>
The following ABAP program can call the transformation:
DATA xml_string TYPE string.
DATA: BEGIN OF struc,
col0 TYPE i VALUE 0,
col1 TYPE i VALUE 1,
col2 TYPE i VALUE 2,
col3 TYPE i VALUE 3,
col4 TYPE i VALUE 4,
col5 TYPE i VALUE 5,
col6 TYPE i VALUE 6,
col7 TYPE i VALUE 7,
col8 TYPE i VALUE 8,
col9 TYPE i VALUE 9,
END OF
struc.
DATA: BEGIN OF
result,
compa TYPE i,
compb TYPE i,
compc TYPE i,
END OF
result.
CALL TRANSFORMATION
...
SOURCE root = struc
RESULT XML
xml_string.
CALL TRANSFORMATION
...
SOURCE XML xml_string
RESULT root =
result.
After the deserialization, the components of resultreceive the values of the third, forth and tenth component of struc.