Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Data Interfaces and Communication Interfaces →  ABAP and XML →  Simple Transformations →  ST - Serialization and Deserialization →  ST - Literal Template Content 

ST - tt:text, Literal Text

Other versions: 7.31 | 7.40 | 7.54

Syntax


...>literal<...

...><tt:text>literal</tt:text><...

Effect

Here, literal stands for literal text. Each piece of content of a template that is not an element (in other words, not positioned between < >), is literal text. This includes line breaks and blanks that are combined under the term whitespace.

The first line above shows unmarked literal text. In ST programs, literal text can also be marked using the ST command tt:text, indicated in the second line. The difference between these variants is that an unmarked literal text literal is ignored during serialization and deserialization if it contains nothing but blanks. A marked text is never ignored.

Serializing Literal Text

If a literal text is not ignored, then all its characters are written to the target XML document. This includes any whitespace. No characters are written if a text is ignored.

Deserializing Literal Text

The literal text of the XML source document is compared character by character (including blanks and line breaks) to the ST program and consumed. This means that at every position in the inbound stream at which there is literal text, the same text must appear in the ST program and must also be considered there.


Note

Use literal texts with other characters (except whitespace) sparingly; always identify them with tt:text and do not extend them over multiple lines because line breaks and indents are potential sources of errors during deserialization. The only intended use of unmarked texts is to format the ST program with line breaks and blanks (indents). To avoid problems during deserialization of literal texts, you can skip them using tt:skip.


Example

The following ST program contains four elements, X1 to X4, with literal text.

<tt:transform
  xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:template>
    <X0>
      <X1> a b c </X1>
      <X2><tt:text> d e f </tt:text></X2>
      <X3>     </X3>
      <X4><tt:text>     </tt:text></X4>
    </X0>
  </tt:template>
</tt:transform>

The result of a serialization is as follows, whereby the blanks in X3 are ignored:

<X0><X1> a b c </X1><X2> c d e </X2><X3/><X4>     </X4></X0>

This XML document can itself be deserialized again by the above ST program. The ST program below raises the exception CX_ST_MATCH_ELEMENT, because no blanks exist in the ST program for the blanks in the inbound stream within X4, due to the missing tt:text marking.

<tt:transform
  xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:template>
    <X0>
      <X1>a b c</X1>
      <X2><tt:text>d e f</tt:text></X2>
      <X3>     </X3>
      <X4>     </X4>
    </X0>
  </tt:template>
</tt:transform>

The ST program below cannot deserialize the XML document either, because it expects line breaks in X1 and more blanks due to the indent.

<tt:transform
  xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:template>
    <X0>
      <X1>
        a b c
      </X1>
      <X2><tt:text>d e f</tt:text></X2>
      <X3>     </X3>
      <X4>     </X4>
    </X0>
  </tt:template>
</tt:transform>

The ST program below can deserialize the XMLdocument; all elements are skipped using tt:skip.

<tt:transform
  xmlns:tt="http://www.sap.com/transformation-templates">
  <tt:template>
    <X0>
      <X1><tt:skip /></X1>
      <X2><tt:skip /></X2>
      <X3><tt:skip /></X3>
      <X4><tt:skip /></X4>
    </X0>
  </tt:template>
</tt:transform>