How to add automatic numbering to elements
This guide will help you set up basic numbering for elements. This numbering can be shown in places like widgets and in places where the element's title
is used. This way of numbering elements will not change the content of the document. This guide uses the DITA figure element (<fig>
) throughout its examples.
What you need
-
A basic understanding of XPath and XQuery
Create an XQuery module
The first step is to create an XQuery module. Create a file named figure
in the src
directory of a package. The XQuery module will be loaded automatically.
This XQuery module is used to declare a function which, in this case, returns a number for a given figure element.
Add the reducer
The second step is adding the reducer in a configure
file using the add
function.
Use the reducer in a label query widget
The reducer function added in the previous step can now be used in the element configuration everywhere XPath queries are allowed.
Your editor now shows a label widget in the top right corner of figure frames. The label shows the number of the figure element.
Frequently asked questions
How can automatic numbering be restarted per document or section?