12. elementTemplate

  name = NMTOKEN
  parent = XPath (subset)
  selectable = (false|true|override) : true
  dynamic = boolean : false
  Content: [ any element ]?

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 elementTemplates with the same name from the configuration.


“Title” of the element template.

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


With grammars such as W3C XML Schema and RELAX NG, different element types may have save the same element name.


  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.


  1. Specify parent="author".

  2. Specify parent="figure|table".


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.


Value true specifies that this element template embeds one or more XPath 1.0 expressions which are to be evaluated before the element template is used. See Example 6.2, “Dynamic element template” below.

  • XPath 1.0 expressions delimited by curly braces ("{ }").

  • The enclosed XPath expressions are evaluated as strings. This means that these enclosed expressions must be found inside attribute values, text, comment or processing-instruction nodes.

  • If you want attribute values, text, comment or processing-instruction nodes to actually contain curly braces, then you must escape these curly braces by doubling them (that is, "{" becomes "{{" and "}" becomes "}}").

  • The context node (that is, ".") used during the evaluation is a copy of the element template itself (before its processing by XXE). This copy is detached from the document being edited at the XPath expression evaluation time (that is, empty "..").

  • It's possible to access the document being edited at the XPath expression evaluation time by referencing variable $parentElement. After the element template is processed by XXE, the resulting element is inserted in the document being edited and the parent of the newly inserted element is $parentElement.

Example 6.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">

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

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

<cfg:elementTemplate xmlns="" name="simpara" selectable="override">
    <listitem cfg:template="simpara" />
    <listitem cfg:template="simpara" />
Example 6.2. Dynamic element template
<cfg:elementTemplate name="now" dynamic="true" selectable="override"

With the above element template, a newly inserted DocBook 5 date element automatically contains the current date.

In order to compute the current date, some standard Java™ methods are used as XPath extension functions in XMLmind XML Editor - Support of XPath 1.0.