Einführung dynamischer Variablen in Dokumentvorlagen

Graubereich zwischen Dokumenten und Textstücken beiderseitig ausgefüllt
English 中文

Bis vor kurzem hat das A2E-Textbausystem darauf bestanden, dass alle Textbausteine in endgültiger Form vorliegen müssen, bevor eine Dokumentvorlage mit ihnen gefüllt werden kann. Mit dieser scharfen Trennung sorgten wir für eine sehr schnelle Kompilierung der Vorlage, ließ aber viele Wünsche offen, die wir uns nun behutsam erfüllen.

1 Lage

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

  1. 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
  2. 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 Einführung dynamischer Variablen in Dokumentvorlagen
‘sut’ FILTER value Graubereich zwischen Dokumenten und Textstücken beiderseitig ausgefüllt
titsut ${tit}: ${sut}
titsut.expand Einführung dynamischer Variablen in Dokumentvorlagen: Graubereich zwischen Dokumenten und Textstücken beiderseitig ausgefüllt
‘[ title ] ${1}’ FILTER call(tit) [ title ] Einführung dynamischer Variablen in Dokumentvorlagen
‘$(dt|title): ${1}’ FILTER fill(tit, ‘dt=:call:sqbrackets’) [ title ]: Einführung dynamischer Variablen in Dokumentvorlagen
‘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 Dynamik
dok.lab(‘en’) Dynamics
dok.tit Einführung dynamischer Variablen in Dokumentvorlagen
dok.tit(‘de’) Einführung dynamischer Variablen in Dokumentvorlagen
dok.sut Graubereich zwischen Dokumenten und Textstücken beiderseitig ausgefüllt
dok.sut(‘zh’) 文書與多語字串之間的灰色地带已從雙面填充
var = ‘a2e’;var.lab a2e
var.lab(‘zh’) 亞通歐
var.des Wir schreiben, übersetzen und programmieren hier Texte in Sprachen Asiens und Europas, insbesondere Chinesisch, Japanisch, Deutsch und Englisch über aktuelle Entwicklungen in einigen Zeichensystemen und in den Realitäten, die damit bezeichnet werden.
var.des(‘zh’) 我們在此用中、日、德、法、意、俄等語文編寫、翻譯、自動生成我們關心的領域的時事評論及背景分析文章,希望在此過程中開拓出一些使得這種多語文編寫工作得以更加輕便地進行的手法以及自由軟件。
var = ‘tit’;var.cit(‘adv_pub’) Automatische Datenverarbeitung
‘tit’ FILTER cit(‘adv_pub’) Automatische Datenverarbeitung
‘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.

  1. dok: oas_pub
    • url: /oas
    • tit: A2E Ostasien-Sprachendienste
    • des: Die Vielfalt der Sprachen bietet uns Gelgenheit, neue Kulturtechniken zu entwickeln. Im Simultandolmetschen von Chinesisch und Japanisch auf technisch-juristischem Gebiet sind wir führend.
    • lab: Sprachendienste
    • meta sut: Chinese, Japanese, German, English et al
    • meta filter sut: Chinese, Japanese, German, English et al
  2. dok: eupat
    • url:
    • tit: Patentierbarkeit und Demokratie in Europa
    • des: Die Europäische Patentorganisation (EPO) erteilt jedes Jahr gegen den Buchstaben und Geist des Gesetzes Tausende von Patenten auf “computer-implementierte” Algorithmen und Geschäftsmethoden, und versucht nun schon zum dritten Mal, diese Praxis auf dem Wege europäischer Rechtssetzung durchzusetzen. Eine Glaubensgemeinschaft ministerieller Patentbeamter hält die Legislativgewalt fest in ihrer Hand und betreibt eine Karikatur von “Innovationspolitik”, die uns exemplarisch vor Augen führt, was heute in Europa schief läuft.
    • lab: eupat
    • 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?
  3. dok: apr_pub
    • url:
    • tit: Mimosenschutz verdrängt Meinungsfreiheit
    • des: In Deutschland werden ehrliche Kritiker regelmäßig mit ruinösen Klagen mundtot gemacht. Das im Internet neu erwachte politische Engagement der Bürger wird gedämpft, das produktive Potential der neuen Kommunikationsformen eingeschnürt. Die Einschränkungen der Äußerungsfreiheit sind weit umfassender und repressiver als einer demokratischen Gesellschaft zuträglich sein kann. Deutschland verletzt systematisch Artikel 10 der Europäischen Menschenrechtskonvention. Der Bundestag ist gefordert.
    • lab: Aufruf
    • 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.

Tabelle 3.1: predoks
text ADV: Automatische Datenverarbeitung: Kein Gebiet der Technik: Fortschritte im Bereich der Automatische Datenverarbeitung (ADV) asiatischer und europäischer Texte
text 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.
text 03: Thema: Begriff und Anwendung: Hier sammeln und destillieren wir unsere Erkenntnisse zum Thema .
text Was War: Datenverarbeitung im März 2009: Verlauf des Monats: Was diesen Monat im Bereich Datenverarbeitung passierte.
text 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 Unterlagen

[ ADV | 2009 | 03 | Was War | Nachrichten | Dynamik ]
Gültiges XHTML 1.0! Gültiges CSS! deplate
http://a2e.de/adv/09/03/dynaarbs07
© 2009-03-07