Editing with templates

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.

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:

Visualizing template elements

When a template is displayed, Amaya shows the XTiger elements under the form of colored frames that surround XHTML elements.

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 changes. In this path, XTiger elements are displayed in gold and XHTML elements in black. For XTiger elements, it is not the element name (use, bag, repeat) but the label of these elements, as declared in the template.

Selecting templates

You can select your own templates, or use the templates available on the Amaya web site at

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 use the file browser (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 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 recommended but not mandatory. When you create a new document instance, you can also choose a template that is not in that list.

Creating an instance document

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 an instance document

When a template instance is created or opened, Amaya displays side by side the Formatted view and the Structure view of the document.

In the Formatted view:

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.

In the Structure view:

Editing in a repeat element

In 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 a new occurrence of the repeated structure is allowed, + icons are displayed at locations where you are allowed to create it. When you click on these icons, you get a pop-up menu that tells you what can be inserted at that position. 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.

Editing in a use element

Most 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.

Editing in a bag element

In 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 sub-menus of the contextual menu. The available component elements are also listed in the Insert and Append sub-menus of the contextual menu.