company logo

Fixed text and text references

Templates typically refer to fixed text and text references. Moreover, one may use template conditions or template iteration in order to create conditional or iterative text output.

Fixed text

Fixed text will be copied to the target document using styles and local text formatting as being defined for the fixed text in the document. Any paragraph or text style defined for the document template may be used for fixed text, except OSI styles, which are reserved for marking OSI template elements. One may, however, refer also to list and image default styles provided in the template.

Text reference

In order to refer to text data provided by the database, one may define text references, which are operation paths enclosed in $...$. An operation path may refer to a single text field, but also to an operation. When referring to an operation, the operation result will be displayed. Operations referenced as text references should return elementary data (string, number date etc.).

Values which are not string types are converted to string values. All string values are converted to UTF8. Reserved XML characters as < and > are translated to corresponding XML values(&gt; &lt; etc).

Special support is provided for Qt rich text fields, which are usually stored in the database when editing text in rich text edit controls (GUI framework). Text formatting of rich text edit fields is converted to Open Document Standard text formatting, i.e. appropriate styles are selected or created when generating the document. .

When generating documents including Qt rich text edit fields, text formats and styles used in the formatted text may conflict with styles used in the document template. In general, paragraph styles are taken from the document template, while local formats (spans) are translated to document styles as long as possible.

Document templates support unordered and ordered lists defined within a rich text field as well as embedded graphics. Embedded graphics are copied to the document's image folder. Tables in rich text fields are not yet supported. Also special formatting options as line or block indent will be ignored. As long as rich text fields do not use very sophisticated text formatting, they are converted nearly 1:1 to the document.

When defining text references, only one style should be assigned to the text reference. Changing the style within the text reference may cause errors in the generated document.

$topics.topic(0).definition.name$

$topics.topic(0).GetExampleText()$

Conditional text output

In order to generate conditional text output, one may insert code lines defining the condition. This may cause problems, since text after a code line always starts a new paragraph. In order to create conditional text within a paragraph, template conditions may be defined. Template conditions must not be marked as OSICode and must not contain local formatting.

This is, however, rather sensitive, since any additional character as format information etc. will destroy the template expression. Hence, it is suggested to call a template expression, instead.

Dear $if sex == male$Mr.$else$Mrs.$end$ $last_name$,

Comment: better solution

My name is $GetTitle$ $last_name$.

Comment: template expression

STRING GetFirstName()

if ( sex == male )

  return ( "Mr." );

else

  return ( "Mrs. ");

end

  

  

Template iteration

In order to combine text elements within a text paragraph one may call template while construct. Since this is difficult to read, because all statements have to be written in one line, it is suggested to cal an OSI functions defined in the template, instead. The same solution is suggested for switch blocks an other more complex string computation.

My name is$while first_name.next$ $first_name$$end$ $last_name$.

Comment: better solution

My name is $GetFirstName$ $last_name$.

Comment: template expression

STRING GetFirstName()

return ( first_name[0] + ' ' +

         first_name[1] + ' ' +

         first_name[2] );

end