將動態變量在文書模板中使用

文書與多語字串之間的灰色地带已從雙面填充
English Deutsch CN TW

直至最近為址,亞通歐文章組成系統要求所有文章組件為需展開至最終形態方可用它們填充一個多語文書模板。這樣涇渭分明的好處在於文書模板的編譯很快。現在我們大致維持這個好處,而同時又允許用戶必要時在文件中調用、擴張、填充動態變量。

1 現狀

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 將動態變量在文書模板中使用
‘sut’ FILTER value 文書與多語字串之間的灰色地带已從雙面填充
titsut ${tit}: ${sut}
titsut.expand 將動態變量在文書模板中使用: 文書與多語字串之間的灰色地带已從雙面填充
‘[ title ] ${1}’ FILTER call(tit) [ title ] 將動態變量在文書模板中使用
‘$(dt|title): ${1}’ FILTER fill(tit, ‘dt=:call:sqbrackets’) [ title ]: 將動態變量在文書模板中使用
‘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 動態
dok.lab(‘en’) Dynamics
dok.tit 將動態變量在文書模板中使用
dok.tit(‘de’) Einführung dynamischer Variablen in Dokumentvorlagen
dok.sut 文書與多語字串之間的灰色地带已從雙面填充
dok.sut(‘zh’) 文書與多語字串之間的灰色地带已從雙面填充
var = ‘a2e’;var.lab 亞通歐
var.lab(‘de’) a2e
var.des 我們在此用中、日、德、法、意、俄等語文編寫、翻譯、自動生成我們關心的領域的時事評論及背景分析文章,希望在此過程中開拓出一些使得這種多語文編寫工作得以更加輕便地進行的手法以及自由軟件。
var.des(‘de’) 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 = ‘tit’;var.cit(‘adv_pub’) 亞通歐多語數據處理
‘tit’ FILTER cit(‘adv_pub’) 亞通歐多語數據處理
‘tit’ FILTER cit(‘adv_pub’, ‘de’) Automatische Datenverarbeitung

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: 亞通歐語言信息事業
    • des: 在德國慕尼黑市中心提供中、日、英、德及其他語種翻譯公證件,會場同聲傳譯,信息系統多語化等服務的事務所
    • lab: 翻譯
    • meta sut: Chinese, Japanese, German, English et al
    • meta filter sut: Chinese, Japanese, German, English et al
  2. 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?
  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.

Table 3.1: predoks
text 數據處理: 亞通歐多語數據處理: 非技術領域: 多種文字的信息處理工具, 方法, 服務
text 己丑: 數據處理 2009: 一年咬文嚼字雜記: 中、日、德、英文同聲傳譯,各種文書公證翻譯、多語資料編程等本職工作之餘所感
text 03: 關於: 概念及應用: 此處吾等將搜集並提練關於本主題的知識及觀點
text 歷程: 己丑三月數據處理日誌: 本月回顧: 這一段時間裡在數據處理領域中所發生之事務。
text 新聞: 在亞通歐多語超文系統中設定新聞頻道: 如何將每頁的右欗上供應適合的新聞: 通過設定文件中的某些語句可以全會控制並調節該頁的新聞欗的構造,也可以接受模本中所規定的預設值。以下進行初步說明。

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 資源

[ 數據處理 | 己丑 | 03 | 歷程 | 新聞 | 動態 ]
XHTML 1.0 合格! 樣式表合格! deplate
http://a2e.de/adv/09/03/dynaarbs07
© 2009-03-07