Symbols and symbol lists
Symbols are used in document templates to enable application programs to customize documents with data appropriate to the current task, such as a user name or order number. Symbols represent variable data that is resolved at the time the template is added to the document - at the time the DOCUMENT CREATE or DOCUMENT INSERT command is issued.
0012345
,
and used in a document template as follows:
Thank you! Your order number is &ORDER_NUMBER;.
the finished document after symbol substitution will be:
Thank you! Your order number is 0012345.
A symbol reference is included in a document template at the place where the value of the symbol is to be substituted in the text of the completed document. The symbol reference consists of the symbol name, preceded with an ampersand (&) and terminated with a semicolon (;). You can use a symbol in any location within the document template. You can also include a default value for the symbol at any location in the document template, using the embedded template command #set.
An application program that creates a document using the document template needs to assign values to the symbols that are to be substituted when the template is used. You can do this using the DOCUMENT SET command or the DOCUMENT CREATE command.
ORDER_NUMBER=0012345&COUNTRY=Germany
The values that have been assigned to symbols are held in a symbol table. There is a symbol table associated with each document template. When the #set command is used, or when an application provides a value for a symbol, the symbol name and its associated value are added to the symbol table. If the symbol already exists in the symbol table, its value is replaced by the new value. A symbol definition provided by an application overrides a default value provided by a #set command.
When a document template is inserted into a document by the DOCUMENT CREATE or DOCUMENT INSERT command, symbol substitution is carried out for all the symbols that exist in the symbol table, using their current values as specified in the symbol table. If the symbol has not been specified by the application program or by a #set command, no symbol substitution takes place, and the finished document includes the symbol name or the #echo command specifying the symbol.
When you use a template containing symbols, you need to specify the values you require for the symbols before inserting the template into a document. If you insert a template, but you have not assigned values to the symbols in it, the symbols will never be substituted. (This can occur if you create a document from a template without specifying a symbol list or symbol values.) After you have inserted the template into a document, you cannot change the values that CICS has put in the document in place of the symbols. If you specify values for symbols after inserting the template, your values are placed into the symbol table and used the next time that the template is inserted into a document, but your changes do not affect the values that have already been inserted into the document.
Data format for symbols and symbol lists
The support for symbols and symbol lists in the DOCUMENT application programming interface is designed to interpret data with a content type of application/x-www-form-urlencoded , as described in the HTML 4 specification topic Form content types . This is the format in which data is returned when it has been entered into a form on a Web page. (Web pages are the most common use for CICS document templates.)
firstname=Irving&lastname=Berlin
The values are normally data which the user has entered in the form.
However,
if the data entered in the form contains characters that have a
special meaning
in the format of url-encoded data, the characters entered in the form
need
to be distinguished from those used to delimit the name and value
pairs. To
achieve this, a process of character escaping is performed. An escaped
character
is a character that has been replaced by the three-character sequence
%xx
,
where
xx
is the hexadecimal value of the ASCII encoding of
the character.
The ampersand (&), the equals sign (=), and also the percent sign (%), because it is used to introduce the escape sequence, must all be escaped in url-encoded data. Because the space character is often used as a delimiter, it is always escaped too. However, because spaces are so common, the URL-encoded data type allows spaces to be encoded as plus signs (+), rather than as an escape sequence. This in turn means that any plus signs entered in the form must also be escaped.
sum 8+11=19
rate 19%
composers George & Ira Gershwin
the escaped url-encoded representation
of this data is:
sum=8%2b11%3d19&rate=19%25&composers=George+%26+Ira+Gershwin
The
space characters in the values have been encoded as plus signs, and the
plus
sign, equals sign, percent sign, and ampersand in the values have been
encoded
as escaped sequences.
- Spaces do not have to be escaped. A space can be represented as a single space, or as a plus sign, or as the escape sequence %20.
- The delimiter between the name and value pairs does not have to be an ampersand. You can specify an alternative delimiter using the DELIMITER option of the command.
Normally, unescape processing is carried out for the values of symbols when they are put into the symbol table, so any characters specified using special coding are converted into the intended character. For example, plus signs are converted to spaces, and escape sequences are converted to the correct characters. However, if you specify the UNESCAPED option on the DOCUMENT CREATE or DOCUMENT SET command, no conversion takes place, and the symbol values are put into the symbol table exactly as you entered them.
Symbols in HTML comments
Within HTML comments in document templates, symbols are normally ignored, and the CICS document handler does not carry out symbol substitution. HTML comments are delimited by the opening markup <!--
and the closing markup
-->.
If you want to have symbol substitution occur within an HTML comment in a document template, you can use symbols in place of the opening and closing delimiters of the comment, and use the #set command in the document template to provide the opening and closing delimiters as the values for those symbols. If you do this, CICS carries out symbol substitution for the whole of any comment around which you use the symbols in place of the delimiters.
<!--#set var=OC value='<!--'-->
<!--#set var=CC value='-->'-->
&OC; A comment containing my text &SYM; &CC; If the application program assigns a value of 'Example text' to the symbol SYM, CICS substitutes the value of that symbol and also of the symbols OC and CC, producing the HTML output: <!-- A comment containing my text Example text -->