Documents templates

From ISPWiki
Jump to: navigation, search

An XML-file with required information is generated when you print documents (invoices, contracts, etc.).

Based on the XML-file and document template, the billing system will generate a new document for printing. A document template, in its term, can be based on EJS or XSLT.

An XSLT-template includes a string starting with <xsl:stylesheet. Otherwise, it will be considered an EJS-template.

Starting from BILLmanager 5.90.0, EJS and XSLT templates are available in the billing system. EJS-templates are created by default, but XSLT-templates will be available by clicking "Reset" and "Create".

Limits on usage of XSLT and EJS templates

  • You cannot print EJS and XSLT-based documents at the same time;
  • You cannot print an EJS document, if at least one of its appendixes is based on XSLT;
  • You cannot print an XSLT document, if at least one of its appendixes is based on EJS.


An XML-file will be converted to a JSON file. You can view its content with the out=doc_json paremeter. E.g., an address bar will look like:, if you change doc_print into doc_json, a JSON-file that is used by EJS-templates, will be displayed.

All templates that are used for printing a certain document, are saved in separate files in the temporary tmp/doctmpl_XXXXXX directory.

In the base template, the  %TEMPLATES% macro is changed into directives of other templates in a correct order.

The etc/scripts/doctmpl.js script running on node.js will start:

/usr/bin/node --harmony /usr/local/mgr5/etc/scripts/doctmpl.js

A resulting HTML-page will be passed to browser.


An XSLT-template uses a source XML-file. You can view the contents of the file with the out=xml parameter E.g., when you print a contract, the address bar will look like:, if you change doc_print into xml,an XML-file that is used by XSLT-templates will be displayed.

A key value in the XSLT-template has the node <xsl:template match="maintemplate">. maintemplate will be changed into a required value so that the template will be applied for the correct node in the XML-file. в процессе обработки заменяется на нужное значение, в результате чего шаблон применяется для правильного узла из XML-файла.

All XSLT-templates that are used for printing a certain document are grouped into a single XSLT-document.

This XSLT-document is applied to the XML-file resulting in generation of a HTML that will be displayed by the browser.