|
1 Situation
We needed a possibility to store unexpanded variables and expand them later only during document processing, even though this meant giving up a virtuous guiding principle of our document processing system.
This is needed for two different reasons
-
It does not make sense to store big expanded text chunks in the dbm database and in fact the SDBM_File package does not allow this at all, setting a severe limit of 1K
-
Sometimes expansion must happen in the document, using variables that could have been (re)defined within the document
We can now define the following normal dynamic variable in the template
tslv2 = $(lnol|${tslv2_0}|${tslv2_1}|${tslv2_2}|${tslv2_3}|${tslv2_4})
and expand it later in the template, using a vmethod expand , which expands recursively until there is no more expansion work to do, e.g.
[* tslv2.expand *]
The expand vmethod does not even need to know which variables are dynamic. It is up to the document template creator to decide whether the variable in question might need expansion.
The expand vmethod was enriched further so as to become a full equivalent to the tb filter and thus make that filter superfluous.
2 Methods for operations on dynamic variables
Beside the simple expand method, we have a few more vmethods:
- value
-
treat the argument as a variable name and return its value (simplified expansion)
- expand
-
expand the argument as a mlht/maketext (vocabulary building language) expression
- call
-
apply arguments
- fill
-
apply arguments and interpret function calls
- funcall
-
invoke a builtin function of the mlht/maketext language, with
All of these vmethods are also available as filters. A filter is slightly bulkier to use and to program, but has the advantage that it can be used not only on a variable but also directly on a string value.
Below are some sample text blocks, based on definitions which illustrate the use of these functions:
template source |
compiled result |
var=‘tit’;var.value |
Introducing dynamic variables into document templates |
‘sut’ FILTER value |
Accomodating a grey area between vocabulary and templates |
titsut |
${tit}: ${sut} |
titsut.expand |
Introducing dynamic variables into document templates: Accomodating a grey area between vocabulary and templates |
‘[ title ] ${1}’ FILTER call(tit) |
[ title ] Introducing dynamic variables into document templates |
‘$(dt|title): ${1}’ FILTER fill(tit, ‘dt=:call:sqbrackets’) |
[ title ]: Introducing dynamic variables into document templates |
‘23’ FILTER funcall(‘dnumpad’, ‘6’) |
000023 |
3 Document reference functions
We have moreover added some functions that allow us to retrieve properties and text chunks from other documents. We have used these to replace our menu generation system so that the menu is now entirely written using the Template toolkit.
template source |
compiled result |
var = ‘perl_a2e_pub’;var.url |
/adv/perl/A2E |
‘perl_a2e_pub’ FILTER url |
/adv/perl/A2E |
dok.predoks.join(‘, ‘) |
adv_pub, adv_pub09, adv_pub0903, adv_pub_int0903, rss090314 |
var = ‘adv_pub0903’;var.subdoks.join(‘, ‘) |
adv_pub_int0903, adv_pub_ont0903 |
var = ‘adv_pub0903’;var.postdoks.join(‘, ‘) |
adv_pub0904 |
dok.lab |
Dynamics |
dok.lab(‘en’) |
Dynamics |
dok.tit |
Introducing dynamic variables into document templates |
dok.tit(‘de’) |
Einführung dynamischer Variablen in Dokumentvorlagen |
dok.sut |
Accomodating a grey area between vocabulary and templates |
dok.sut(‘zh’) |
文書與多語字串之間的灰色地带已從雙面填充 |
var = ‘a2e’;var.lab |
a2e |
var.lab(‘zh’) |
亞通歐 |
var.des |
We write, translate and program texts in languages of Asia and Europe, especially Chinese, Japanese, German and English, regarding current developments in semiotic systems and the realities to which they refer. |
var.des(‘zh’) |
我們在此用中、日、德、法、意、俄等語文編寫、翻譯、自動生成我們關心的領域的時事評論及背景分析文章,希望在此過程中開拓出一些使得這種多語文編寫工作得以更加輕便地進行的手法以及自由軟件。 |
var = ‘tit’;var.cit(‘adv_pub’) |
ADP Advances at A2E |
‘tit’ FILTER cit(‘adv_pub’) |
ADP Advances at A2E |
‘tit’ FILTER cit(‘adv_pub’, ‘zh’) |
亞通歐多語數據處理 |
3.1 Generating meta info about arbitrary documents
Languages can be listed in order of preference, meaningful defaults are chosen.
-
dok: oas_pub
-
url: /oas
-
tit: A2E Language Services
-
des: Authoritative and sophisticated translating, interpreting and multilingual computing services, involving languages of Asia and Europe, by an experienced team of geeks, operating from an office in the center of Munich.
-
lab: Services
-
meta sut: Chinese, Japanese, German, English et al
-
meta filter sut: Chinese, Japanese, German, English et al
-
dok: eupat
-
url:
-
tit: Patentability and Democracy in Europe
-
des: The European Patent Organisation (EPO) is continuing to grant thousands of monopolies on “computer-implemented” algorithms and business methods every year, against the letter and spirit of the written law, and is now, for the third time, pushing for European legislation that would impose this practise on reticent national courts. Patent interests in combination with inter-governmental lawmaking have formed a caricature of “innovation policy” and thereby are helping us to see clearly what is going wrong in Europe today and what the alternatives are.
-
lab: EU Patent
-
meta sut: How can industrial property be subordinated to modern economic policy?
-
meta filter sut: How can industrial property be subordinated to modern economic policy?
-
dok: apr_pub
-
url:
-
tit: Freedom of Speech
-
des: Personality Rights, Privacy Rights and Copyright are being emphasised by courts at least here in Germany in a way that is detrimental to the Communication Society of the digital age
-
lab: Appeal
-
meta sut: Communication vs Privacy
-
meta filter sut: Communication vs Privacy
3.2 Example: Table of Superordinate Documents of this Node
We see the language default choice algorithm at work here too.
Table 3.1: predoks
ADP: ADP Advances at A2E: Not a Field of Technology: Automated Data Processing (ADP) on Asian and European texts –- tools, methods and support services. |
2009: Datenverarbeitung 2009: Notizen des Jahres: Erfahrungen beim Simultandolmetschen von Chinesisch, Japanisch, Englisch und Deutsch, Übersetzungen, Programmierung vielsprachiger Dokumentation und was das Jahr sonst noch brachte. |
03: Thema: Begriff und Anwendung: Hier sammeln und destillieren wir unsere Erkenntnisse zum Thema . |
Was War: Data Processing im March 2009: Verlauf des Monats: Was diesen Monat im Bereich Data Processing passierte. |
Nachrichten: Einrichtung von RSS-Nachrichtenkanälen in A2E MLHT: Wie wir die rechte Spalte jeder Webseite mit passenden Meldungen anreichern: Mittels mehr oder weniger detaillierter Angaben in der Konfigurationsdatei des Multilingualen Hypertextsystems (MLHT) und in Vokabulardateien können wir eine detaillierte Kontrolle über die Zusammensetzung der Nachrichtenkanäle ausüben oder uns mit einigermaßen sinnvollen Voreinstellungen zufrieden geben. |
4 CAVEATS
The filter cit , by loading the whole vocabulary of a quoted document into memory side by side with that of the current document, provides a great mechanism for commenting a source document. This vocabulary includes the whole vocabulary of superior files and template used by that file. Use with care, i.e. only for real quotations, on one or two source documents that you may want to comment on, not for substituting the proper vocabulary building mechanisms. Otherwise our system could quickly lose its compactness and speed.
5 BUGS, LIMITATIONS
Variables defined in the document do not thereby become available to the vmethods/filters. The vmethods (e.g. call, fill, funcall) are aware only of the definitions made in the vocabulary file. In the above examples, the verb ‘sqbrackets’ must be defined in the vocabulary file.
6 Resources
|