The lower level of Transmorpher, indeed implementing a transformation, is made of rules (corresponding to XSLT templates). Instead of using only one kind of very general template, Transmorpher provides a collection of very simple-to-use and easy-to-analyze rules.
The advantages of rules are that:
they can be easily understood,
they can be easily implemented through mapping to XSLT (also efficiently implemented),
they can be easily analyzed by an external program.
The rules themselves are very simple templates that can be used for specifying simple transformations of a source. Here is the current set of rules:
maps a particular tag (tag1) to another one (tag2). It can contain remtag, maptag, mapatt, rematt or addatt tags for modifying the content of the matched tags. This is useful for straightforward DTD translation.
transforms all the reference elements in the context of a bibliography element in a bibitem element.
simply removes the subtrees rooted in the specified tag. This is useful for simplifying the structure of the document.
suppresses all abstract elements (and all their content) in the context of a reference element.
for replacing a tree by its subtrees (or text) in a structure (this rearrangement is useful for information gathered from multiple sources).
suppresses all the bibliography elements within another bibliography element (but not their content).
maps a particular attribute to another one.
transforms each issue attribute in the context of a conference element in a number attribute.
simply remove the attributes specified by name.
removes all status attributes and all ISBN attributes in the context of a book element.
adds to the considered elements a particular attribute and value. This enables operations like decoration of a tree with specific primitives. This is useful for decorating a subtree with a particular attribute (e.g. to color all level 1 titles in red).
substitutes each occurrence of the regular expression re in the content of the context path (usually the value of an attribute or the non structured content of an element) by the substitution string ss (which can refer to extracted fragments).
substitutes each number by the same number followed by "e" in the context of the issue attribute of a conference element. resubst is not pure XSLT. It is implemented as a Xalan extension function and uses the gnu.regexp package. It might become a standard feature of XSLT 2.0 (or a standard extension function of XSLT 2.0 implemented with standard Java 1.4 regexp substitution).
All these rule tags can use the context attribute, which enables the restriction of the evaluation context of a rule with an XPath location.
Adding new rule types is not offered yet by Transmorpher but could be in the future
The rule constructs are grouped into rulesets (corresponding to
XSLT stylesheets and which can contain regular XSLT templates). The goal of
these rulesets is the same as XSLT stylesheets with a restricted set of
The rulesets have one implicit input and one implicit output.
In the transformation flow initially provided, there is the strip-abstract ruleset suppressing the abstract elements (and other minor elements) and the elements marked as private.
The apply-ruleset element introduces the use of a ruleset in a process body. Its structure is the following:
The channels, implicit in the writing of the rules, must named when applying a rule set:
The ruleset control scheme is exactly the same as that of XSLT: one-pass top-down evaluation. The apply-ruleset tag has a strategy attribute in which we plan to specify other evaluation strategies.
The ruleset implementation consists of transforming the ruleset in a stylesheet that is processed by Xalan. It is easy to see how these rulesets can be transformed into a proper XSLT stylesheet.
The XSLT stylesheet corresponding to the ruleset above is given below:
The strategic aspect of rulesets is not implemented yet. Currently, since the rulesets are compiled as XSLT transformations, the default strategy can be considered as "outermost-once-with-explicit-calls".
Next chapter: Channels