10.2. Specificities of `selectable="override"`
Prev | 10. elementTemplate | Next

### 10.2. Specificities of `selectable="override"`

- The validity of the contents of an element template having `selectable="override"` is checked before the editing operation is performed. If this contents is found to be structurally invalid, then the element template is ignored and an automatically generated element is used instead.

  Example of a structurally invalid element template (the `linkend` attribute of DocBook 4 element `xref` is missing):

      <elementTemplate name="simple" selectable="override">
        <xref xmlns="" role="LINK" />
      </elementTemplate>

  Note that the above element can be made usable by slightly modifying it:

      <elementTemplate name="simple" selectable="override">
        <xref xmlns="" linkend="???" role="LINK" />
      </elementTemplate>

  The above element template is data-type invalid (`"???"` is not a valid ID), but structurally valid.

- Unlike W3C XML Schema, with RELAX NG, different element types may have save the same element name regardless of the element type of the parent. DocBook 5 example: there are 3 different `indexterm` element types that may be inserted into almost any parent element.

  In the case of the above example, XXE lists these 3 different `indexterm` element types in its Edit tool as: `indexterm`, `indexterm-2`, `indexterm-3`. These automatically generated names are hard to understand. Here comes `selectable="override"`. This facility may also be used to give user-friendly names to the competing element types listed by XXE.

  DocBook 5 example:

      <elementTemplate name="singular" selectable="override">
        <indexterm
          xmlns="http://docbook.org/ns/docbook"><primary></primary></indexterm>
      </elementTemplate>

      <elementTemplate name="startofrange" selectable="override">
        <indexterm xmlns="http://docbook.org/ns/docbook" xml:id="???"
                   class="startofrange"><primary></primary></indexterm>
      </elementTemplate>

      <elementTemplate name="endofrange" selectable="override">
        <indexterm xmlns="http://docbook.org/ns/docbook"
                   class="endofrange" startref="???" />
      </elementTemplate>

  In the case of the above example, the Edit tool will not list `indexterm`, `indexterm-2`, `indexterm-3`. Instead it will list `indexterm(singular)`, `indexterm(startofrange)`, `indexterm(endofrange)`.

Prev | Up | Next
10.1. Adding empty text nodes to your element templates | Home | 11. help