将动态变量在文书模板中使用

文书与多语字串之间的灰色地带已从双面填充
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