About Arbortext Styler > Adding Generated Text > Advanced Formatting of Titles and Numbering > Example: Start Chapter Numbering Based on Attribute Value
Example: Start Chapter Numbering Based on Attribute Value
This example describes how to set the number of a chapter to the value of the number attribute declared for the chapter element, for example number=”13”. If the numbering of a chapter is set in this way, you will be permitted to publish the chapter as a standalone entity and ensure that its numbering remains correct.
1. In the Elements list, select the chapter element and give it the Division style via the Edit > Style menu option. Assign the division level as required for the chapter.
2. Select the title element and give it the Title style.
3. Select the title in chapter context and set it to be numbered by navigating to the Generated text category and selecting the Number option in the Numbers and Bullets field.
4. Click the Details button to open the Division Title Number dialog box.
5. Configure numbering as required for the division, ignoring the Start At option for the time being. Exit the numbering dialog box.
6. In the Elements list, create a condition for the title in chapter context that tests that the attribute number has any value.
If your DTD or schema assigns a default value to the number attribute you can skip this step since the attribute will always have a value when it appears. Otherwise you must create a condition that tests for the attribute having a value or Arbortext Styler will throw an error when it attempts to apply the configured numbering and does not encounter a Start At value.
7. Click the Details button to open the Division Title Number dialog box again.
8. Click the Start at button to open the Start At dialog box.
9. In the dialog box, configure the following settings:
Start at: Attribute
Element to get attribute from: Parent
Attribute name: number
10. Save the change and exit the dialog box, then exit the division numbering dialog box.
11. When previewing or publishing you will now see that chapters based on the chapter element are numbered according to the value of their number attribute. If you subsequently publish a chapter as a standalone element, for example if a document contains a single chapter, you will notice that the chapter number remains the same.
If you are setting a Start At value for numbering where the numbered element is identified via a condition, the setting will only be applied if the condition is true for the first element in the numbering family. Using the example described above, if the If attribute “number” of parent element is assigned any value condition is not true for the first title in chapter context in the document, Start At value(s) will be ignored for every chapter in the document. Numbering will be applied if configured but it will start from 1.
This means that you also cannot reset the Start At value partway through the document, for the same element.