InnoTecSol >ICS >ICS Version: 0.7.2425 Documentation >http(x) >http(x) >http(x) Templates
ICS Version: 0.7.2425
http(x) Templates
The http(x) templates offer the means to generate output dynamically including variables provided by the http protocol or the default handler.
Templates are stored in files with the extension .iht (ics http templates). Templates are language specific therefore any template has an language suffix e.g -en.iht for an english specific language file.

A template file (iht) consists of a valid xml document with template instructions. A valid template comprises


<?xml version="1.0" encoding="UTF-8"?>
<yasittf:transform>
	<yasittf:template>
	...
	</yasittf:template>
</yasittf:transform>
	

The root tag must be yasittf:transform

The template is introduced by yasittf:template tag

Within the template tag html tags or template instructions can be specified.

Also include templates with extension .ihi are supported. These must have the same format as the template files and can be included via the directive


	<yasittf:include template="header"/>
	

The attribute TEMPLATE specifies the name of the include file without language extension. The language extension is added automatically based on the main template language extension.

Variables

The template instructions allow access to variables as defined by the scenario. There are 3 different type of variables:

  • Variables
  • References
  • Results

Variables are exposed by the specific scenario (e.g. dir listing) and its content can be access from the template by e.g. the <yasittf:value/> instruction.

References are references to the variables thus just a another name for a specific variable. Reference can be set within loops and accessed by e.g. the <yasittf:value/> instruction.

Results are special variables that functions operate on. Results can be set by the yasittf:eval instruction or by functions.

The template syntax supports the following template instructions.

Outputting variable values can be achieved via yasittf:value tag.


<yasittf:value var="/httpx/request/location"  format="html" />
		

The instruction will read the value of the variable /httpx/request/location" and insert it into the document replacing the yasittf:value tag.

The yasittf:value tag supports 3 type of variables

  • var - variables queried
  • ref - references set e.g. during foreach loops or calculations yasittf:eval (see below)
  • result - result variables set e.g. during function evaluation

Format

The format attribute set to "html" allows to copy the complete html tags contained within a variable node to be taken over into the output document. This way html snippets can be included. Please note that output formatting should be done via css style-sheets.

Outputting the name of a variable can be achieved via yasittf:name tag.


<yasittf:name ref="S" />
		

The instruction will read the name of the variable referenced by S and insert it into the document replacing the yasittf:name directive tag.

This is specially helpful if a loop on an array is performed and the node name of the array index contains data.

The yasittf:name tag supports 2 type of variables

  • var - variables queried
  • ref - references set e.g. during foreach loops or calculations yasittf:eval (see below)

Looping at array variables can be achieved via yasittf:foreach tag


<yasittf:foreach var="/httpx/request/header" iterator="S" index="SI">
	<yasittf:value ref="S/location" />								
</yasittf:foreach>
		

Loops over an array (above /httpx/request/header) and sets the current array item as reference (S). The current index is set into a result variable (SI). Attributes iterator and index are both optional. The reference can the be accessed with e.g. a yasittf:value tag

Foreach also supports reference variables to allow loops in loops.


<yasittf:foreach var="/httpx/request/variable" iterator="S">
	<yasittf:foreach ref="S/subvariable" iterator="U">
		<yasittf:value ref="U" />			
	</yasittf:foreach>	
</yasittf:foreach>	
		

Sections of a template can be generated based on conditions utilizing the yasittf:conditional tag.


<yasittf:conditional>
	<yasittf:match ref="DE/TYPE" operator="EQ" func="yasittf:result('D')" cast="string" >
		Contents of reference DE/TYPE is D
	</yasittf:match>		
	<yasittf:default>
		Displayed if content of DE/TYPE is not D
	</yasittf:default>
<yasittf:conditional>
		

The yasittf:conditional tag introduces a conditional section, which can have multiple matching sections as well as a default section.

The <yasittf:match ref="DE/TYPE" operator="EQ" func="yasittf:result('D')" cast="string" > tag validates whether the contents of the specified variable (var), reference (ref) or result variable (result) matches the result of the function specified by func using the specified operator.

The <yasittf:default> tag is used when none of the match sections were met.

Operators

The following operators are supported:

  • EQ - equal
  • LT - less than
  • LE - less equal
  • GT - greater than
  • GE - greater equal

The attribute cast forces a comparision based on a specific data type. Supported casts are

  • string
  • integer
  • float

If the cast attribute is not specified the comparision treats the variables as string type, thus string comparison is performed.

Functions

Any function is supported that can also be used within the eval instruction (see below).

The yasittf:eval tag can be used to execute a function and assign the result to a result variable for further processing.


<yasittf:eval func="yasittf:refvalue(S/subvariable, string, 0)" result="E" />		
		

assigns the value of the reference S/subvariable to the result variable E

The value of a result variable can be retrieved e.g. via the yasittf:result function


<A href="yasittf:result(E)"></A>		
		

or via the yasittf:value instruction


<yasittf:value result="E" />
		

Template functions can be called with yasittf:eval tag, the yasittf:match tag or within HTML attributes.

Template functions operate on result variables except for yasittf:refvalue, yasittf:refname, yasittf:varvalue and yasittf:varname.

The usage of functions within the yasittf:match tag is explained in Conditional generation

The usage of functions within the yasittf:eval tag is explained in Evaluation

Functions can also be called within html attributes.

The function yasittf:refvalue specified within the href attribute of the anchor tag reads the content of the reference value and replaces the html href attribute content.


<html>
	<body>
		<A href="yasittf:refvalue(S/subvariable, string, 0)">text</A>
	<body>
</html>
	

Replaces the content of the href attribute with the value of the reference variable S/subvariable.

The following functions are supported:

The function yasittf:varvalue reads the content of the specified variable.


<html>
	<body>
		<A href="yasittf:varvalue(var, string, 0)">text</A>
	<body>
</html>
		

The first parameter of the function expects the name of the variable to be read.

The second and third parameter specifies the output format. Currently only string and 0 (unlimited) length is supported.

The function yasittf:refvalue reads the content of the specified reference variable.


<html>
	<body>
		<A href="yasittf:refvalue(S/subvariable, string, 0)">text</A>
	<body>
</html>
		

The first parameter of the function expects the name of the reference variable to be read.

The second and third parameter specifies the output format. Currently only string and 0 (unlimited) length is supported.

The function yasittf:refname reads the name of the specified reference variable.


<html>
	<body>
		<A href="yasittf:refname(S/subvariable)">text</A>
	<body>
</html>
		

The function yasittf:varname reads the name of the specified variable.


<html>
	<body>
		<A href="yasittf:varname(var)">text</A>
	<body>
</html>
		

The function yasittf:refattrib reads the value of the attribute of the specified reference variable.


<html>
	<body>
		<A href="yasittf:refattrib(S/subvariable, 'attrib')">text</A>
	<body>
</html>
		

The function yasittf:varattrib reads the value of the attribute of the specified variable.


<html>
	<body>
		<A href="yasittf:varattrib(variable, 'attrib')">text</A>
	<body>
</html>
		

The function yasittf:result reads the content of the specified result variable as set by e.g. yasittf:eval or returns the specified value.


<A href="yasittf:result(E)"></A>		
		

The value of a result variable identified by E is retrieved.


<A href="yasittf:result('E')"></A>		
		

The value E is retrieved. This can e.g. be used by yasittf:match as comparison term.

Concatenates a arbitrary number of strings.


<yasittf:eval func="yasittf:concatenate('#',L, '|', F)" result="Z" />		
		

whereas static strings can be specified within quotes or result variables via their variable name.

Searches the string for the first character that matches any of the characters specified, starting at position start pos until end pos is reached.


<yasittf:eval func="yasittf:findfirstof(string, findcharstring, startpos)" result="Z" />		
		

whereas static strings can be specified within quotes or result variables via their variable name.

Extracts the substring at position startpos until endpos. If endpos is not specified it extracts until then end of string.


<yasittf:eval func="yasittf:substr(string, startpos, endpos)" result="Z" />		
<yasittf:eval func="yasittf:substr(string, startpos)" result="Z" />		
		

whereas static strings can be specified within quotes or result variables via their variable name.

Replaces characters within a specified result variable or static string


<yasittf:eval func="yasittf:replace(Z, ' ','_')" result="X" />		
		

replaces all spaces of result variable Z with underscores and stores the result in X. The parameters can be either static strings or result variables.

Counts the characters of the specified result variable or static string


<yasittf:eval func="yasittf:strlen(Z)" result="X" />		
		

stores the count of the string contained in variable Z in the result result variable X.

Calculates the modulo of the specified values.


<yasittf:eval func="yasittf:mod(DEI, '2')" result="X" />		
		

calculates the modulo 2 of the specified result variable DEI. The parameters can be either static values or result variables. The divisor must not be 0.

Calculates the division of the specified values.


<yasittf:eval func="yasittf:div(DEI, '2', 'float')" result="X" />		
		

calculates the divions 2 of the specified result variable DEI casting both values as well as the result to float. The parameters can be either static values or result variables. If float cast is not specified integer values are assumed. The divisor must not be 0.

Calculates the multiplication of the specified values.


<yasittf:eval func="yasittf:mul(DEI, '2', 'float')" result="X" />		
		

calculates the multiplication 2 of the specified result variable DEI casting both values as well as the result to float. The parameters can be either static values or result variables. If float cast is not specified integer values are assumed.

Calculates the addition of the specified values.


<yasittf:eval func="yasittf:add(DEI, '2', 'float')" result="X" />		
		

Adds 2 to the specified result variable DEI casting both values as well as the result to float. The parameters can be either static values or result variables. If float cast is not specified integer values are assumed.

Calculates the substraction of the specified values.


<yasittf:eval func="yasittf:sub(DEI, '2', 'float')" result="X" />		
		

Substracts 2 of the specified result variable DEI casting both values as well as the result to float. The parameters can be either static values or result variables. If float cast is not specified integer values are assumed.

Round the specified value with the given precision.


<yasittf:eval func="yasittf:round(DEI, '2')" result="X" />		
		

Rounds the specified result variable DEI with a precision of 2. The parameters can be either static values or result variables.

Percent encodes a specified string.


<yasittf:eval func="yasittf:urlencode(DEI)" result="X" />		
		

Percent encodes the content of result variable DEI. The parameters can be either static values or result variables.

The following variables are available in error templates

The server information (Version) is made available via the variable /httpx/server


<yasittf:value var="/httpx/server" />
		

The host information (request host and port) is made available via the variable /httpx/host


<yasittf:value var="/httpx/host" />
		

The port information (listener port) is made available via the variable /httpx/port


<yasittf:value var="/httpx/port" />
		

The URL requested is made available via the variable /httpx/request/url


<yasittf:value var="/httpx/request/url" />
		

The method of the request is made available via the variable /httpx/request/method


<yasittf:value var="/httpx/request/method" />
		

The http version used in the request is made available via the variable /httpx/request/version


<yasittf:value var="/httpx/request/version" />
		

The Request Header fields are made available via the array variable /httpx/request/header/


<yasittf:value var="/httpx/request/header/" />
		

The header fields can be queried via the foreach loop.


<yasittf:foreach var="/httpx/request/header" iterator="RH">
	<yasittf:name ref="RH" />: <yasittf:value ref="RH" />
</yasittf:foreach>
		

The response status code is available via the variable /httpx/response/statuscode


<yasittf:value var="/httpx/request/statuscode" />
		

The extended error code is available via the variable /httpx/response/errorcode


<yasittf:value var="/httpx/request/errorcode" />
		

The response header fields are available via the variable /httpx/response/header


<yasittf:value var="/httpx/response/header" />
		

Additionally to the variables that are accessible in the error templates, the following variables are available in directory listing templates

The requested sort string is made available via the variable /httpx/response/sortstring


<yasittf:value var="/httpx/response/sortstring" />
		

The requested directory is made available via the variable /httpx/response/dir


<yasittf:value var="/httpx/response/dir" />
		

The requested directory entries are made available via the array variable /httpx/response/dir

The directory entries can be queried via the foreach loop.


<yasittf:foreach var="/httpx/response/dir" iterator="ENTRY">
	..
</yasittf:foreach>
		

An entry has the following properties:

  • FILENAME
  • SIZE
  • TYPE
  • DATE

FILENAME

The FILENAME variable contains the name of the directory entry.

SIZE

The SIZE variable contains the size of the directory entry.

TYPE

The TYPE variable contains the type of the directory entry. This can be either "D" for directory or "F" for file.

DATE

The DATE variable contains the last modified date of the directory entry.