PTC ALD in Arbortext Styler > Components of Documents and Templates > Creating New Content from the Main Content Stream > Indexes > Formatting with Indexes
Formatting with Indexes
Once an index control stream and index references are in place, further steps are required to create and display the index.
Create the index
The formatting process must be able to access the index control stream so it has the necessary information to create the index. Set the fFormat.index property to point to a valid fIndex object.
The fFormat object is then used as part of either an fTemplate.format() method or an fPublish object used in an fTemplate.publish() method call.
Specify the text stream to which to write the index data
Set the fIndexItem.output to the required text stream. This stream is normally a .ix tag type (fTag.TYPE_INDEX).
If you are creating XML in the index, for example when working with advanced index items, it is recommended that any XML and whitespace properties are set when creating the output tag. For example, if you want to use context matching to associate formatting with the markup, this stream needs an associated context control stream.
Generate the index content
There are three ways of instructing PTC Arbortext Layout Developer to generate the index content, specified by the fIndexItem.generationMode property):
After formatting — fIndexItem.AFTER_FORMAT
When the formatting process has finished, PTC Arbortext Layout Developer populates the target index output tag with the index content.
When the output tag is referenced — fIndexItem.ON_REFERENCE
The index output tag can be referenced either directly by calling the tag inline with an element of the same name, or using the fFormatting.formatStream() method. When PTC Arbortext Layout Developer encounters this reference, it generates the content for the tag and populates the tag based on the information available at that point in the formatting process. If other entries are provided after that stream is referenced, they will not appear in the index.
On demand — fIndexItem.ON_COMMAND
The inline command fFormatting.buildIndex() instructs PTC Arbortext Layout Developer to generate the named index output stream at a particular point. Use this method to create the index before its output is required.