About Arbortext Styler > Arbortext Styler Dialog Boxes > Insert Element Content Dialog Box
  
Insert Element Content Dialog Box
This dialog box displays when you select Insert > Element Content in the Generated Text Editor for an element or a cross reference object. It allows you to insert the content of the current element, or another element, in the generated text for an element.
Please note that when you insert element content, all attributes of copied elements are also copied, including any ID attribute with an assigned value. You may need to make further changes to your document if the copied or copy element is to be used as the target of a cross reference, to avoid the ambiguity introduced by the presence of multiple elements with the same ID attribute value.
The Insert Element Content dialog box contains the following options:
Element selection - Defines the element in the document whose content should be inserted. Once you have defined the element, select the type of content to be extracted from the options contained in the Insert field.
The dialog box contains the following selection options:
Current Element - The element whose generated text you are setting
By name and occurrence-within-ancestor - A specific occurrence of an element within a particular ancestor.
Name - The element for which Arbortext Styler should search. You can select an element from the list or type in the element’s name.
* 
If you enter the name of a namespaced element in this field, you will not be prompted to declare the namespace if it does not already exist. Ensure you have declared the namespace for the stylesheet by creating an element with the applicable prefix, or the element selection you enter in this field will not be valid
Occurrence - The occurrence of the selected element in its ancestor.
Select All to insert the content of all occurrences of the named element that occur within the element specified in the Within field.
If the Only content radio button is selected in the Insert group, the combined content from all occurrences is inserted inline, and each piece is wrapped by a Styler Formatting Element (_sfe:CollectionItem), contexts of which can be formatted to include separators to place each piece of content in a legible list.
For example, suppose you include three occurrences of a productname element in a document based on the XML DocBook doctype (for example the sample document Arbortext-path/samples/styler/transport.xml) as shown below:
<productname>XML DocBook doctype</productname>
<productname>Arbortext Editor</productname>
<productname>Arbortext Styler</productname>
It is possible, using the All option, to output a list of these product names in a single line, for example as the title of a formalpara element. Set the generated text for the title in formalpara context to insert All occurrences of the productname element from within the relevant element. Preview the document for print and you will see that the title of the formalpara element contains the list XML Docbook doctype, Arbortext Editor, and Arbortext Styler as its generated text. If you examine the SFE _sfe:CollectionItem you will see that there are four contexts for that element, each dealing with a specific position of an entry in a collection: first, not first or last, last and everywhere else. Since we have three entries in our list we need to examine the first, not first or last and last contexts - look at the generated text for each one:
first (deals with the first element in the list, in this case XMLDocbook doctype): no generated text
not first or last (deals with entries that are neither the first not the last ones in the list, in this case Arbortext Editor, the second entry): set to insert a comma before element content
last (deals with the last entry in the list, in this case Arbortext Styler): set to insert a comma and the text “and” before element content
You can see that these SFEs have been set to construct a coherent list out of a set of entries extracted from the document content.
If the Element and content radio button is selected in the Insert group, the _sfe:CollectionItem UFE does not wrap the items, since there are already elements to separate them.
Within - The ancestor element within which the selected element occurs.
If ID matches IDREF - The element that contains an ID attribute whose value matches the value of the IDREF attribute on the element whose generated text you are setting. Note that this option is not available when you are creating generated text for a cross reference object.
Name of IDREF attribute on xxx element (where xxx is the name of the element whose generated text you are setting) - the attribute on the element whose generated text you are setting
Note that this occurrence option is only enabled if the element whose generated text you are setting has an IDREF attribute, and will only match elements that have an ID attribute.
By XPath - The element matched by an XPath expression
Expression - the XPath expression that will match the required element. Note that the expression must result in a node-set of element nodes.
* 
If you enter the name of a namespaced element in this field, you will not be prompted to declare the namespace if it does not already exist. Ensure you have declared the namespace for the stylesheet by creating an element with the applicable prefix, or the XPath expression you enter in this field will not be valid
Insert - Determines what type of content to insert in the generated text. The options are:
Only content: all the content of the element, including markup, but not the element itself.
Element and content: inserts both the element and its content.
The inserted content and/or element (and any child elements they include) will be formatted via normal Arbortext Styler rules. It may be desirable to create a special context for the element if you want it to be formatted differently when it appears in this generated text. For example, if the element <x> inserts element <y> and its content, you might want to create a context for y anwhere in x to control how element <y>'s contents will format when used in <x>'s generated text.
The following example illustrates how Within and Occurrence work. Suppose you have the following markup in your document:
<Section>
<Author>...</Author>
<SectInfoRef/>
</Section>
and you want the SectInfoRef element to generate information including the content of the Author element. You would carry out the following steps to enable this:
Select By name and occurrence-within-ancestor
Name: Author
Occurrence: 1st
Within: Section
This tells Arbortext Styler to insert the content of the first Author element that occurs anywhere inside the Section element that contains the SectInfoRef element. Note that the example would work just as well if the SectInfoRef occurred before the Author element.
On the other hand, assume you had the following markup:
<Section>
<SectInfo>
<Author>...</Author>
</SectInfo>
<SectInfoRef/>
</Section>
While it would still work to set Within to Section, it would not work to set Within to SectInfo, because SectInfo is not an ancestor of SectInfoRef.
Select the menu option View > Generated Text > Show in Arbortext Editor to have your generated text displayed when you preview the document in Arbortext Editor view.