10.1. Advanced options

Use only if the parent element matches the following XPath

Normally an element template is suggested by the Edit tool whatever the parent element where this template is to be inserted. But in some cases, generally with W3C XML schemas and with RELAX NG schemas and not with DTDs, you'll want the template to be usable only in certain contexts.

Example: your schema defines two title elements: a job title which is a possible child element of person and author elements and the optional title (i.e. a caption) of table and figure elements.

You intend to define several job title templates. Example: element template "title(arch)" is defined as <title>Software Architect</title>.

Of course, you don't want to see "title(arch)" listed by the Edit tool when you are about to give a title to a table.

In such case:

  1. Click on the "Use only if the parent element matches the following XPath" radio button.

  2. Type XPath expression "person|author" in the text field below the radio button.

This means: suggest "title(arch)" but only when the template is to be inserted in a person or an author element.

Note that a very small subset of XPath is supported here:

This replaces the default, automatically generated, element template

This option is best explained by an example.

Out of the box, if you insert a table element in a DocBook document, in fact, you insert predefined table template called "table(simple)".

The "table(simple)" template has two rows and two columns which makes it much more useful that the default, automatically generated, table template which just contains a single cell[22].

Note that when a single named template such as "table(simple)" replaces the default, automatically generated, element template, the Edit tool does not display its label. For example, in the case of the DocBook table, the Edit tool displays "table"[23] and not "table(simple)".

Now, what if you prefer to use a table having 3 rows and 3 columns plus a thead header as your default table?

  1. Create the table by inserting the rows, cells and header you want.

  2. Select this table.

  3. Use OptionsCustomize ConfigurationSave Selected Element as Template.

  4. The "Existing element templates" list shows you that a predefined template already replaces the default, automatically generated, one. You can see this because "table(simple)" is displayed in italic.

    You need to label your own template like the existing one in order to replace it. Therefore specify "simple" in the Label of the element template field.

  5. Click on check box "This replaces the default, automatically generated, element template".



[22] The default, automatically generated, element template is the simplest, valid, element allowed by the schema.

Most of the time this heuristic gives good results. However in some cases, the default, automatically generated, element template, is, well, too simple to be useful.

[23] There is no ambiguity and this is shorter to type.