ABAP Keyword Documentation → ABAP − Reference → Data Interfaces and Communication Interfaces → ABAP and XML → Transformations for XML → ST - Simple Transformations → ST - Modularization with Subtemplates
ST - tt:template, tt:context, Create Subtemplate
Other versions: 7.31 | 7.40 | 7.54
Syntax
<tt:template name="tmpl">
[<tt:context>
[<tt:root name="root1" [[line-]type=...] />
<tt:root name="root2" [[line-]type=...] />
...]
[<tt:parameter name="para1" [[s-|d-]val="def1"]
[kind="knd1"] />
<tt:parameter name="para2" [[s-|d-]val="def2"]
[kind="knd2"] />
...]
[<tt:variable name="vari1" [[s-|d-]val="val1"] />
<tt:variable name="vari2" [[s-|d-]val="val2"] />
...]
</tt:context>]
...
</tt:template>
Effect
Like the main template, subtemplates are defined with tt:template. Using the attribute name, define a unique name tmpl for the subtemplate.
Data in Subtemplates
In a subtemplate, custom data can be declared: tt:context can be used to define a context for the commands tt:root, tt:variable, and tt:parameter. The command tt:context is allowed only in subtemplates and the commands tt:root, tt:variable, and tt:parameter are allowed in a template only within tt:context.
Like in the main template, there are three categories of data, all in a single namespace:
- Data roots
- Parameters
- Variables
Addressing Data in Subtemplates
A subtemplate without separate data roots creates a separate tree structure of data nodes whose root node is the current node from the calling position in the calling template. As a prerequisite for calling a template like this, the current node must be defined at the call position. At the start of the subtemplate, this root node is also the current node of the subtemplate. In a subtemplate like this, the current node can be set as described for main templates, but in contrast to main templates, it is never undefined. Data nodes outside of the tree structure of the subtemplate cannot be addressed. In particular, the data roots of the main template cannot be addressed with .name.
Addressing the data nodes of a subtemplate with own data roots happens exactly as described for the main template. As long as no current node is defined, the data roots of the subtemplate can be addressed using name. After they are obscured by a current node, the only way to address them is with .name.
Note
Figuratively speaking, a subtemplate without separate data roots works exclusively with the substructure of the main template tree structure whose root nodes are bound.
Examples
See Call Subtemplate.