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.
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:
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.
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.
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.
use
element that includes a string. The command asks the user for a label.
That label is free and is used for the selection path displayed in the
status bar. The selection must be string and becomes the initial value
of the use element.
use
.
If the selection is empty, un dialog proposes the list of elements
that can be inserted at that position and asks the user for the label
to be associated with the new use element. A use
element
is generated with an empty content.
If an element of the target language (div, h1, h2, p, ...) is
selected, a use
element that allows one to insert this
element type is generated at that position. The selected element
becomes the initial content of the use element. The command only asks
the user for a label.
repeat
of the current selected use
element.
The command asks the user for a label. That label is free and is used
for the selection path displayed in the status bar.
bag
element. The command asks the user for a label. That
label is free and is used for the selection path displayed in the
status bar.When a document instance is displayed, Amaya shows the XTiger elements under the form of colored frames that enclose XHTML elements.
use
element is shown as a dashed blue boxbag
element is shown as a dashed green boxrepeat
element is shown as a box with a attribute
element is not displayed in the main view, as
it only impacts the Attributes tool.The XTiger elements can also be seen in the structure view. Open this view with the Show structure entry of the Views menu. In the structure view, XTiger elements are displayed in gold, while the XHTML elements are in blue. XTiger elements are also shown in the Source view, but with no special color.
Another way to understand the nesting of XTiger elements with XHTML elements
is the selection path displayed in the status bar of the
window (at the bottom of the window). There, you can see the list of all
elements in the structure of the document from the root element to the current
selection. It is updated every time the selection is changed. In this path,
XTiger elements are displayed in gold and XHTML elements in black. For XTiger
elements, it is not the name of the element that is displayed there
(use
, bag
, repeat
) but the label of
these elements, as declared in the template.
You can select your own templates, or use the templates available on the Amaya web site at http://www.w3.org/Amaya/Templates/
To ease selection among your favorite templates, there is a Templates section in the Preferences dialogue (Edit/Preferences, or amaya/Preferences under Mac OS X). Use it to register the templates that Amaya proposes when you create a new document. When registering a local template, you can call a file browser with the browse button to locate and select the files to be added to the list. You can also enter the URI of remote templates in the input area below the list. Use the buttons on the right side of the list to remove a template or to change the order of templates in the list.
Registering templates in this list is not mandatory. When you create a new document instance, you can also choose a template that is not in that list.
To create a new document instance from a template, use entry New/New document in the File menu. It displays a dialogue where you can select:
Editing is allowed only inside the repeat
, use
,
and bag
elements, i.e. within the colored dashed boxes. The rest
of the document is the fixed part of the template and can not be modified.
repeat
elementIn a repeat
box, you can create new instances of the repeated
structure or you can delete one. This is controlled by the template, which may
impose a minimum and/or a maximum number of occurrences of the repeated
structure.
When creating new occurrences of the repeated structure is allowed, + icons are displayed at locations where you are allowed to create new occurrences. When you click on these icons, you get a pop-up menu that tells you what can be inserted at that position. By clicking in that pop-up menu, you create a new occurrence of the corresponding type. In some cases the template offers only one type of occurrence. The pop-up menu then contains a single entry, to clearly state what will be created. If you click outside the menu, nothing is created.
Another way to create new occurrences of the repeated structure is to select an existing occurrence, or to put the caret at the end of an occurrence, and to press the Enter key. A new occurrence of the repeated structure is then created, provided the maximum number of occurrences is not reached yet. The type of the new occurrence is then the same as the one that was selected when pressing the Enter key.
When an existing occurrence is empty or fully selected and the Backspace or Delete key is pressed, the element is deleted, provided the minimum number of occurrences is not reached yet.
use
elementMost use
elements (blue) allow you just to enter free text or
to freely replace/edit existing text. Other use
elements offer a
choice between different types of elements that can be inserted at that
position. In that case, a blue triangle icon is displayed in the top left
corner of the box. By clicking this icon, you can select one of the allowed
types through a pop-up menu. When you have chosen a type, the corresponding
structure is generated and you can freely edit its content.
bag
elementIn a bag
box (green), you can insert any number of elements of
the types specified by the template. When you want to insert a XHTML element,
do it the usual way provided this type is allowed by the template. It may
happen that some elements are not allowed by the template. The allowed elements
are listed in the Insert and Append submenus
of the contextual menu. The available template components are also
listed in the Insert and Append submenus of
the contextual menu.