company logo

Creating documents by means of OSI templates

When running OSI templates, the result created by the template is written to a thread-global variable. This variable might be accessed from within the template or OSI function in order to write the result to a file (SystemClass::TemplateResult()) When not creating the output file by the OSI template or function, the template result might be retrieved by the application (see example below). In order to clear the template result, SystemClass::ResetResult() should be called before calling the OSI template.

The example below shows a simple fragment for calling an OSI template (e.g. for generating HTML documents).

bool ...fragment(Property &ph,odaba::String filename) {

odaba::String      html_template_name;

// set option variables requested by templates

  if ( ph.positioned() )

    Option("ItemLoid") = ph.instanceLoid();

  html_template_name = GetHTMLTemplateName(); // provide HTML template name

  ph.executeExpression("SystenClass::ResetResult()");

  ph.executeExpression(html_template_name);

// write to file:  ph.executeExpression("SystenClass::TemplateResult()").toString();

}