Generation of documents. Easy and free

Continuing the theme of generating documents based on templates, I want to discuss the creation of the document in which in addition to the relatively permanent parts are parts, the form and content of which depend entirely on the data. Ie we are not talking about trivial fields are filled or simple tables. We are talking about tables with a variety of textures with different number of columns under one header and the table view is determined by the data.

To implement such a document in the template you can pre-define separate possible table rows, give them a name, and then from these rows to assemble a table in the same way as the beads onto the thread as the threads are stacked layer by layer into the fabric with the desired pattern.
In the process of generation of these auxiliary rows are deleted from the document. What kind of line should be inserted in the document is defined by its name. A named string does not have to be a string table, it can be the text with the desired display attributes.

Thus it is possible to collect the document, where the text alternates with a variety of tables. The pattern is set in addition to named strings, the place where we start line-by-line printing. The task of the programmer in this case is reduced to the formation of XML, which in addition to data will indicate which string to display them. Thus achieved almost complete (only the name string specifies the format) to separate data from presentation. And it is nice that the row names can be meaningful, and the generation occurs quickly.

In conclusion, I would add that places in the template where you can type data lines may be several. Every place has its own name (identifier). In the XML input, you must pass in a tag is the name of the print line by line data. Naturally, the print data must be sorted in the order of rows.
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

Templates ESKD and GOST 7.32 for Lyx 1.6.x

Monitoring PostgreSQL + php-fpm + nginx + disk using Zabbix

Custom table in MODx Revolution