
9. Editing with templates
9.1. What is a template?
Templates are used to produce multiple documents of the same type. A template is a skeleton
representing a given type of document, expressed in the format of the final documents to be produced
(XHTML, for instance). The format of the final documents is called the target language and must be an
XML language.
In a template, the skeleton document contains some statements, expressed in the XTiger language
(eXtensible Templates for Interactive Guided Editing of Resources), that specify how this minimal
document can evolve and grow, while keeping in line with the intended type of the final document.
Documents produced from this skeleton following the XTiger statements are called instances of the
template. Some parts of the template may be frozen, if they have to appear in document instances as they
are. Some parts may be changed when producing an instance document, some others may be added either
freely or under some constraints.
The file containing a template must have a .xtd extension.
A template comes often with a set of accompanying resources (images, style sheets, scripts). A template
is a web resource, that can be stored in the local file system or shared on a remote web server.
9.2. Creating a template
You can create your own templates, using the XTiger language. However, Amaya provides a specific
support for creating or updating templates.
The proposed approach is to:
• Create first a skeleton of the document instance (.html file) you want to generate.
• Select the Template (Tpl) tab of the Elements tool and click on the first entry to generate a
template (.xtd file) from that document skeleton.
• When a template document is selected, several entries of the Template tool are available:
◦ The Create and use a component entry generates a component that will be displayed in
the head of the template document. The current content of the selection becomes the
content of the component.
A use element that allows one to insert that component is created at the current
position of the document. The selection must be valid (a set of complete elements or a
string). The command asks the user for the component name. That name must be
unique.
Note: The content of the component won't be edited in template instances. The user
has to insert use and/or bag elements inside the component to define editable areas.
These editable areas can be inserted before or after the creation of the component.
◦ The Create and repeat a component entry generates a component that will be
displayed in the head of the template document and a use element inside a repeat
element. That command is a shortcut of the Create and use a component and Repeat
the current use commands.
◦ The Create a new types union entry generates a union which defines a new type as a
choice between several basic types (number, string), elements from the target
language (div, h1, h2, p, ...), or component names. The current selection has no effect.
The command asks the user for the union name. That name must be unique.
9. Editing with templates
25
Comentários a estes Manuais