About Arbortext Styler > Publishing XML Documents as RTF Files > Publishing Scoped Tables of Contents in RTF Files
  
Publishing Scoped Tables of Contents in RTF Files
The process below describes how to configure a scoped table of contents (TOC), for example a TOC for each chapter of a document, that will be generated when your document is published to RTF output. In general, you will need to create two sets of UFEs:
Two UFEs that mark the beginning and end of the scope of the TOC (Word calls such markers "bookmarks", though these are unrelated to PDF bookmarks). These UFEs contain RTF edited source
A UFE that makes use of Word field codes to generate the scoped TOC
The RTF-specific tasks required to set up the TOC using these UFEs are given below (note that the process uses chapter as the scope of the TOC):
1. Assign a unique ID to the chapter element for which you wish to create the TOC.
2. In Arbortext Styler, set the Outputs to edit field to RTF, if required.
3. Create a context for the occurrence of the chapter element for which you are creating the TOC, if necessary.
4. Create the UFE that marks the beginning bookmark for the chapter. This UFE must be named _ufe:bookmark_begin to ensure the publishing process identifies it as the marker for the start of the scope. Give the UFE the Hidden style.
5. Create the necessary source edits for XSL-FO RTF output for _ufe:bookmark_begin, so that it will emit a tag for defining the beginning of a Word bookmark range. This range defines the boundary of a TOC's scope.
Refer to the XSL-FO RTF source edits in the distributed sample stylesheet axdocbook.style for an example of the required source edit.
6. Reference the UFE in the generated text of the required chapter context, using the Before-text option. Insert an XPath string such as concat(ancestor-or-self::chapter/@id,'_toc') as a child of the UFE to create a unique bookmark from each chapter ID attribute.
7. Create the UFE that marks the end of the bookmark range for the chapter. This UFE must be named _ufe:bookmark_end to ensure the publishing process identifies it as the marker for the end of the scope. Give the UFE the Hidden style.
8. Create the necessary source edits for XSL-FO RTF output for _ufe:bookmark_end, so that it will emit a tag for defining the end of a Word bookmark range. This range defines the boundary of a TOC's scope.
Refer to the XSL-FO RTF source edits in the distributed sample stylesheet axdocbook.style for an example of the required source edit.
9. Reference the UFE in the generated text of the required chapter context, using the After-text option. Insert an XPath string such as concat(ancestor-or-self::chapter/@id,'_toc') as a child of the UFE to create a unique bookmark from each chapter ID attribute.
10. Create the UFE that will override the default behavior of Arbortext Styler when creating TOCs, by using bookmark-specific options on the Word TOC field (see Word's online help for the TOC field). This UFE can have any name, for example _ufe:rtf_chapter_toc. Give the UFE the Block style.
11. Define the TOC field for this UFE so that it emits a Word TOC field of the following form:
{ TOC \f X \b bookmark_name_toc }
Where X is a Word TOC identifier (see Word online help), and bookmark_name_toc is built from the ID value of the chapter tag plus a _toc suffix.
12. Reference the UFE in the generated text of the required TOC context, for example toc in chapter, using the Before-text option. This will emit the Word TOC field, automatically matching the bookmark_name_toc described above
In all cases the Word TOC identifier coincides with Word TC fields emitted on the appropriate division titles.
The identifiers are automatically generated in upper case alpha order based on the list of tables of contents in Arbortext Styler. For example, the first TOC in the Arbortext Styler list matches the "A" identifier in the Word TOC and TC fields. The second TOC in Arbortext Styler matches the "B" identifier. There is therefore a practical limit of 26 unique tables of contents per stylesheet.
Because these Word identifiers are automatically created and generated in the TC fields (which are the TOC entries) during the publishing process, but the stylesheet developer must enter a hard-coded value, "A", "B", "C", "D", etc., in the TOC field, changes to the list of tables of contents which affect the order of TOCs may mean you need to adjust the values in affected TOCs’ contexts.
* 
If Word Heading styles are used for division titles (see Word online help), the TC fields may be ignored.
You must update fields to see these TOCs. Select all content in the document by pressing CTRL+A, then update the fields by pressing F9.