About Arbortext Styler > Generating Indexes > Generating a Sorted Inline List
  
Generating a Sorted Inline List
This section contains instructions on generating a sorted, inline list of values, where the values are the attribute values of a particular element. The list is auto generated using Arbortext Styler's indexing functionality. For example, here we will demonstrate how to collect the values of the class attribute from the trademark elements contained in the body of a document, remove duplicates, sort them alphabetically and output them with some generated text in the form of a trademark declaration sentence at the end of the document.
In this example, the trademark element has a class attribute which has four possible values, each one generating a specific character, as follows:
trademark class=”copyright”: output copyright symbol
trademark class=”registered”: output registration mark
trademark class=”service”: output service mark
trademark class=”trade” (or no value): output trademark
Some sample markup, which shows the appearance of the element when its attribute is set, is given below:
The object of this procedure is to produce a sorted list of these trademarks as shown below:
Set Generated Text for the Attribute Values of the Selected Element
The first step in creating the list is to set the generated text for each value of the attribute that has been identified as the basis of the list. Once this has been done the required character will appear in the body of the document when text is surrounded by the relevant element markup.
1. Using the InsertCondition menu option, create four conditions for the trademark everywhere context, one for each possible value of the class attribute. Use the New Attribute Test option in the Condition dialog box to enter a test relating to the value of the class attribute for each condition:
"class"="copyright"
"class"="registered"
"class"="service"
"class"="trade" or no value
2. For each condition, include an After-text generated text for the particular class attribute of the trademark element that the condition represents. Here you will specify the character(s) that will be output in your document after the content of the trademark element, when it has a class attribute defined:
"class"="copyright" - ©
"class"="registered" - ®
"class"="service" - (sm)
"class"="trade" or no value - ™
Create and Configure the UFEs to Contain Index Entries
Before an index can be output, you must create a set of User Formatting Elements (UFE) that will contain the index entries intended to make up this particular type of list. Create a wrapper that will hold all the index entry data, then one each for primary and secondary index terms.
1. Create three UFEs via the Insert > Element menu option. Give them explanatory names so they can be easily identified in the Elements list, for example _ufe:tm-wrapper, _ufe:tm-primary, and _ufe:tm-secondary.
2. Give _ufe_tm-wrapper the Index Term (Element Model) style in the Style dialog box, accessed via the Edit > Style menu option. The Index Term (Element Model) Details dialog box opens.
3. On the Roles tab, assign the appropriate role to each UFE in the dialog box.
_ufe:tm-wrapper - Wrapper
_ufe:tm-primary - Level 1 term
_ufe:tm-secondary - Level 2 term
4. Note that the Index Term (Element Model) style has been applied to the three elements.
5. Click OK to save the changes and exit the dialog box.
Create and Configure the UFE to Contain the Index
The UFE that contains the index will define the order and format in which the index entries will be displayed. It will be specified as the output of the particular element in your document that should display the index.
1. Create a UFE using the Insert > Element menu option. Give it an explanatory name so it can be easily identified in the Elements list. Here we have used _ufe:trademarklist.
2. Give the UFE the Index style in the Style dialog box, accessed via the Edit > Style menu option.
3. In the Index Details dialog box, select the index definition object that will format the index from the Index drop down list. Set the language in which the index will be sorted from the Language field.
4. Specify the final output location for the list by inserting _ufe:trademarklist in generated text in one of the elements in your source document. Here the list will be output before element content in the legalnotice everywhere context. In the Generated text category for the legalnotice element, include an Before-text generated text entry.
5. In the Generated Text Editor, select Insert > User Formatting Element and select _ufe:trademarklist. When you close the Generated Text Editor and save your change, the setting will be reflected in the Before-text field for the legalnotice context:
6. Insert a legalnotice element into your document if it does not already exist.
Set Indexing Functionality to Create the List
A sorted list uses indexing functionality to generate its content. Indexing functionality is set to produce a non-default index, i.e. a list based on attribute values of a certain element, with the list's entries sorted alphabetically and duplicates removed before output. Since the indexing functionality is non standard, default indexterm elements cannot be used to form the list's structure. UFEs that simulate the structure of an indexterm are used instead - these were created in the previous section. Note, however, that the index formatting for output is still applied to the default indexing elements. This is described in the next section.
Generated text sets the display of the list:
1. For each condition of the trademark everywhere context, include Before-text generated text to set the content of the _ufe:tm-primary UFE to be the string Suppressed. The word to be used here is not important, this step ensures that all index entries for the list are collected under a single heading. The index now looks similar to the example shown below (note that it is still in index form as the specific formatting that makes the index into a list has not yet been applied):
Use Insert > User Formatting Element to insert the _ufe:tm-wrapper and _ufe:tm-primary UFEs, then enter the text Suppressed into the _ufe:tm-primary UFE:
2. For each condition of the trademark everywhere context, include Before-text generated text to set the content of the _ufe:tm-secondary UFE to be the content of the trademark element. This ensures that the list entries all appear on the same level under the “Suppressed” heading.
Use Insert > User Formatting Element to insert the _ufe:tm-secondary UFE.
Use Insert > XPath String to add the XPath test that identifies the content.
This image shows the Insert XPath String dialog box for the UFE _ufe:tm-secondary, with the XPath expression self::* defined
Each context of the trademark element should now have the same generated text setting:
This is an image of the Generated Text Editor for the trademark element, showing an XPathString element as the content of the UFE _ufe:tm-secondary
Set Index Output Format for the List
Default Styler Formatting Elements (SFE) are already defined in Arbortext Styler to provide output formatting for an index. Since the index must be in the form of a sorted list, these standard SFEs must be modified to give the required display.
Currently the list, if it were to be generated at this stage, would still be in the form of an index, but with all entries grouped under the same heading “Suppressed”:
This is an image of an index listing entries ABC, PTC, Windchill, and XYZ under the S (Suppressed) heading
The object of this final section is to apply the formatting to output the index as a trademark citation:
This is an image of the sentence “ABC, PTC, Windchill, and XYZ are trademarks of PTC Inc.”
To perform the steps listed in this section, ensure the menu option View > Styler Formatting Elements is activated - SFEs will not be available for selection from the Elements list if this has not been done.
1. To suppress output of the alpha header “S”, hide the _sfe:IndexGroupHead_index object name SFE by setting the Hidden field to Yes in the Text category.
2. To remove the dot fill between the index entry and the page locators, delete the generated text object LeaderDots from the _sfe:IndexLocators_index object name SFE, via the Generated Text Editor. You should also hide this SFE from output (as shown in step 1), which ensures duplicates are removed from the list.
3. To suppress output of the page locators, hide the _sfe:IndexPage_index object name and _sfe:IndexEndPage_index object name SFEs by setting the Hidden field to Yes .
4. To configure the output of the content of the index entries, use the _sfe:IndexHeading_index object name SFE, which formats the text content of the index entry. You will need two contexts for this SFE:
_sfe:IndexHeading_index object name in _sfe:IndexEntry_index object name in _sfe:IndexEntry_index object name - this context matches the secondary level index entries that contain the text content of the trademark element. You will most likely need to create this context, via the Insert > Context menu option.
Set this SFE context to an Inline structure in the Breaks category.
_sfe:IndexHeading_index object name everywhere else - this context matches the primary level index entries , i.e. Suppressed. You should not have to create this context, but you do need to suppress its output by setting the Hidden field to Yes (as shown in step 1).
5. To configure the output of the index entries themselves, use the _sfe:IndexEntry_index object name SFE. Create contexts of the SFE and specify the generated text that should be added to each type of index entry in the list to link them together in the list and produce the trademark citation sentence:
ABC
, PTC
, Windchill
, and XYZ are trademarks of PTC Inc.
(first)
(middle)
(middle)
(last)
All the contexts listed below should be given an Inline structure in Breaks category to ensure they do not start a new line.
first: create context first_sfe:IndexEntry_index object name in _sfe:IndexEntry_index object name and set generated text as follows:
no generated text required - the comma after the entry will be generated via the “middle” context
middle: create context _sfe:IndexEntry_index object name in _sfe:IndexEntry_index object name, if it does not already exist, and set generated text as follows:
before element content: add a comma and a space to provide a separator between the first entry and the first “middle” entry, and between all other “middle” entries in the list
last: create context last_sfe:IndexEntry_index object name in _sfe:IndexEntry_index object name and set generated text as follows:
before element content: add single word and with a command and space before, and a space after, to provide a separator between the last “middle” entry and the last entry
after element content: add the string that completes the list: in this case are trademarks of PTC Inc. (with a space in front).
6. To enable the alpha header “Suppressed” to form a part of the list structure but still remain hidden, leave the context _sfe:IndexEntry_index object name everywhere else in place but do not change its existing formatting. Ensure this context has a Block structure by setting this in the Breaks category, and set the right indent to 0 in the Indent category. These last two steps will ensure that the list entries do not overlap each other in the final output.
Publish your document as normal. The list will appear in the nominated element selected in Create and configure the UFE to contain the index.