Why Have Multiple Translation Tables?
Version 1.2 of xmltr added support for multiple translation tables. Before this, only a single translation table could be passed to xmltr.TranslateTree(), which required all translation rules to reside within the same translation table. This presented a limitation if you wanted to do a variety of translations of the same content within a web site. For example, there might be a standard translation which translates xml markup into HTML for web pages. Another translation might act as a filter which extracts and compiles entries for an index page. In this case it is likely that some of the translation rules will be the same for both these translations (e.g. basic text formatting) and the former single-translation-table scheme required duplication of translation rules, which quickly became unwieldy to maintain.
How it Works
Under the new system of multiple translation tables, you can factor translation rules into two or more translation tables. When you call TranslateTree(), you pass a list of translation table addresses (instead of a single scalar translation table address). Xmltr then searches each translation table in turn to find the translation rule which matches a particular tag pattern. The first translation table in the list is the first one searched, and so on. Wildcard or default translation rules in any translation table will take precedence over translation rules (of any kind) in subsequent translation tables i.e. if a wildcard or default translation rule in a particular translation table matches the tag pattern, then the search terminates, and subsequent translation rule tables are not searched for a match. For this reason, it makes sense to put default translation rules into the last translation table in the list so that all translation tables are searched for a match before the default translation rule is invoked.
Techniques for factoring translation rules into multiple translation tables
Here are some suggestions for using multiple translation tables:
Website built using Frontier and xmltr. Documentation also available in pdf format for offline reading. Copyright The Design Group Qld 2000. This page last updated Tue, 7 Nov 2000
|