sapdev logo background
sapdev logo sapdev logo
Comments

SAP ST TT TEXT documentation, setup help and example usage



Return to SAP documentation index


ARTICLE

ST - tt:text , Literal Text

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 in serializations and deserializations if it contains nothing but blanks. A marked text is never ignored.

Serializing Literal Text
If a literal text is respected, then all its characters are written to the target XML data. 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 in deserializations. The only intended use of unmarked texts is to format the ST program with line breaks and blanks (indents). To avoid problems in deserializations of literal texts, they can be skipped 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 data 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 data 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 XML data; 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
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved




ST_TT_TEMPLATE_SUB
ST_TT_TRANSFORM




comments powered by Disqus