Show TOC

Syntax documentationLiteral Text Locate this document in the navigation structure

Use

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. In ST programs, literal text can also be identified using the ST command tt:text.

Literal Text Not Flagged

...>text<...

Literal Text Flagged

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

The difference between these variants is that an unflagged text text is ignored during serialization and deserialization if it contains nothing but whitespace. A flagged 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 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. Use unflagged texts only 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.

End of the note.
Example

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

Syntax Syntax

  1. <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  2.   <tt:template>
  3.     <X0>
  4.       <X1> a b c </X1>
  5.       <X2><tt:text> d e f </tt:text></X2>
  6.       <X3>     </X3>
  7.       <X4><tt:text>     </tt:text></X4>
  8.     </X0>
  9.   </tt:template>
  10. </tt:transform>
End of the code.

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 triggers 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 flagging with tt:text.

Syntax Syntax

  1. <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  2.   <tt:template>
  3.     <X0>
  4.       <X1>a b c</X1>
  5.       <X2><tt:text>d e f</tt:text></X2>
  6.       <X3>     </X3>
  7.       <X4>     </X4>
  8.     </X0>
  9.   </tt:template>
  10. </tt:transform>
End of the code.

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

Syntax Syntax

  1. <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  2.   <tt:template>
  3.     <X0>
  4.       <X1>
  5.         a b c
  6.       </X1>
  7.       <X2><tt:text>d e f</tt:text></X2>
  8.       <X3>     </X3>
  9.       <X4>     </X4>
  10.     </X0>
  11.   </tt:template>
  12. </tt:transform>
End of the code.

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

Syntax Syntax

  1. <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  2.   <tt:template>
  3.     <X0>
  4.       <X1><tt:skip /></X1>
  5.       <X2><tt:skip /></X2>
  6.       <X3><tt:skip /></X3>
  7.       <X4><tt:skip /></X4>
  8.     </X0>
  9.   </tt:template>
  10. </tt:transform>
End of the code.