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

## 10. 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 W3C XML Schema and RELAX NG, different element types may 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 as `element_name`(`element_template_name`) in the Edit tool.

  Value `false` or `override` prevents XXE to list the element template in the Edit tool.

  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 4 example below.

Example 7.1. DocBook 4 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
9.1. Bean properties | Home | 10.1. Adding empty text nodes to your element templates