8. elementTemplate
Prev | Chapter 7. Configuration elements | Next

## 8. elementTemplate

    <elementTemplate
      name = NMTOKEN
      parent = XPath (subset)
      selectable = (false|true|override) : true
    >
      Content: [ any element ]?
    </elementTemplate>

Register with XXE the element template specified in this element.

An element template can include another element template. This is specified by `<`included_element_name `cfg:template="`included_template_name`"/>` inside the body of the template. See DocBook example below.

Note that the validity of the element contained in the `elementTemplate` is not checked by XXE when the configuration file is parsed.

Specifying a `elementTemplate` containing no element may be used to remove all `elementTemplate`s with the same name from the configuration.

name

  ``Title'' of the element template.

  Different element templates may have the same name provided that they contain different elements.

parent

  With grammars such as XML Schema, different element types can have save the same element name.

  Examples:

  1. Element `title` with enumerated values `Doctor` and `Professor` can be inserted inside element `author`.

  2. Element `title` containing plain text, `strong` or `emphasis` children can be used as the title of a `figure` or a `table`.

  In such situation, the XPath attribute `parent` must be used to specify to XXE in which context (that is, for which parent element) the element template can be used.

  Examples:

  1. Specify `parent="author"`.

  2. Specify `parent="figure|table"`.

selectable

  Value `true` specifies that this element template is to be listed using title `element_name`(`element_template_name`) in the dialog box displayed by the Edit → Replace, Edit → Insert Before, Edit → Insert, Edit → Insert After commands.

  Value `false` or `override` prevents XXE to list the element template in the dialog box displayed by Edit commands.

  Value `false` is useful for an element template which is just referenced in a macro-command or in another template and which is not for general use.

  Value `override` specifies that this element template is to be used everywhere the automatically generated element would otherwise have been used. See DocBook example below.

Example 7.1. DocBook example

By default, XXE creates a `listitem` containing a `para`. The following template forces XXE to create a `listitem` containing a `simpara`.

    <cfg:elementTemplate xmlns="" name="simpara" selectable="override">
      <listitem>
        <simpara></simpara>
      </listitem>
    </cfg:elementTemplate>

The `listitem` specified above will also be automatically used inside newly created `itemizedlist`, `orderedlist` and `variablelist`.

By default, XXE creates an `itemizedlist` containing a single `listitem`. The following template forces XXE to create an `itemizedlist` with two `listitem`s.

Note that this template includes the `listitem` template specified above by using attribute `cfg:template`.

    <cfg:elementTemplate xmlns="" name="simpara" selectable="override">
      <itemizedlist>
        <listitem cfg:template="simpara" />
        <listitem cfg:template="simpara" />
      </itemizedlist>
    </cfg:elementTemplate>

Prev | Up | Next
7. documentResources | Home | 9. help