7-2 Administrators Guide for Dynamic Converter
{ footer} body
html { footer}{ unit}
The { unit}, { unit}, { header}, { header}, { footer} and { footer} macros can be ignored for the moment. Their purpose is described in
Macros .
The remainder of the file is regular HTML code with the exception of three macros in the form { insert element=xxx}. Dynamic Converter uses this template plus the
source file to create its output. To accomplish this, Dynamic Converter reads through the template file, writing it byte for byte to the output file unless character mapping is
performed on the template. This continues until the template contains a properly formatted macro. Dynamic Converter reads the macro and executes the macros
command. Usually this means inserting an HTML version of some element from the source file into the output file. Dynamic Converter then continues reading the
template and executing macros until the end of the template file is reached.
In the example above, the first { insert} macro uses the element syntax described in Insert Element: { INSERT}
to insert the title of the document. The second macro inserts the author of the document and the third macro inserts the entire body of the
document. The resulting HTML might look like this HTML that is the result of a macro is in bold:
html body
pHere is the document you requested. A Poem
by
Phil Boutros
p pBelow is the document itselfp
pRoses are redp pViolets are bluep
pIm a programmerp pand so are youp
body html
7.2 Elements
This section covers the following topics:
■
Element Tree on page 7-2
■
Leaf Elements on page 7-4
■
Repeatable Elements on page 7-5
■
Element Definitions on page 7-5
7.2.1 Element Tree
Dynamic Converter uses the concept of an element tree to make various pieces and attributes of the source file individually addressable from within a script template.
The nodes of the element tree are used to generate a path to a specific element, and a period is used to separate the nodes in this path. For example, the path of the author
property of a document is Property.Author.
Script Templates 7-3
For convenience, certain nodes in an element path may be skipped because they represent the obvious default behavior. These nodes include the Sections node
Sections.Current.Body.Title is equivalent to Body.Title, and the Body and Contents nodes Body.Contents.Headings.1.Body is equivalent to Headings.1.Body.
There are two types of elements in the element tree: leaf elements and repeatable elements see
Leaf Elements on page 7-4 and
Repeatable Elements on page 7-5,
respectively.
Important: These nodes may not be skipped if they are the last node
in the path Heading.1.Body is not equivalent to Headings.1.
7-4 Administrators Guide for Dynamic Converter
Figure 7–1 Example of an Element Tree
7.2.2 Leaf Elements
Leaf elements are single identifiable pieces of the source file like the author property Property.Author or the preface of the document Body.Contents.Preface. This type
of element is a valid target for inserting, testing and linking using the { INSERT}, { F} and { LINK...} macros. The last node in this type of path must be a valid leaf node
in the document tree. Valid leaf nodes are shown in italics in the element tree example in
Element Tree .
Script Templates 7-5
7.2.3 Repeatable Elements
Repeatable elements have multiple instances associated with them, like the footnotes in a document Sections.1.Footnotes. This type of element may not be directly
inserted, tested or linked to but its instances may be looped through using the { REPEAT} macro. The last node in this type of path must be a valid repeatable node in
the document tree. Valid repeatable nodes are shown in bold in the element tree example in
Element Tree .
Some templates use { REPEAT} loops to generate one output file per repeatable element. For example, a template may render a presentation file as a group of output
files, with one output file for each slide. When an input file contains an exceptionally large number of sections, it is possible for an operating system to run out of file
handles. See your operating systems documentation or system administrator to find out how many open file handles are allowed. To avoid this extremely rare problem, set
a value for the maxreps attribute of the { REPEAT} macro or configure the operating system to allow more file handles.
7.2.4 Element Definitions