Documentation Center

Using XPath in the configuration

Be careful when using XPath when configuring nodes using the match attribute. Also, and keep in mind specific rules for DITA elements and for placeholders.

Node matching behavior is not always as you expect for some configuration elements.

Specify target elements carefully with XPath in your configuration by using the match attribute in the <x:nodeConfig> configuration.

Let's say the goal is to configure two nodes differently. You need to be careful when specifying the target elements in your XPaths that use the match attribute. For this example, these are the nodes you wish to specify differently:
  • a paragraph
  • a paragraph within a section
When you configuring different names for these nodes, using the name element, the XPath behaves as you expect . It allows you to configure each node separately with different names for paragraphs in different parts of the document.
<x:nodeConfig>
  <x:node match="paragraph">
    <x:name>Paragraph</x:name>
  </x:node>
  <x:node match="section/paragraph">
    <x:name>Section Paragraph</x:name>
  </x:node>
</x:nodeConfig>
On the other hand, the XPath will not work for these configuration elements:
  • template
  • lookup
  • ignoreMixed

When configuring such things as template, Content Editor will only use the last configuration option that is define for a matched node, and the XPath won't work as expected.

DITA

When configuring DITA, the class function should be used to target elements and their specialization. This is an extension to the rule above and more details can be found in an article about XSLT coding practices.

Placeholders

Placeholders are an exception. A placeholder for an element that cannot contain text will not work. However, this placeholder will be visible for children that can contain text, as long as the child itself does not have a placeholder. This only works for direct parents.