Document Developer - instructions > Making the document dynamic > Selecting content within a document dynamically

Selecting content within a document dynamically
You can select content, either a Story or the local content in a Text area, dynamically depending on the input data by adding a Switch. The Switch is related to a Message field or variable. The value of the field or variable determines which Story is used during runtime.
By default, the Switch has local content, but you can share this local content as a Story.
By adding a Case to the Switch, you add a condition to fulfill for either a specific Story or the local content to be used.
You can add a Case that acts as the default, that is, if no other Case matches the input value this default is used.
When you create a Case, the local content of the Text area is used for the Case by default. You can select to use an existing Story for the Case, or you can create a Story from local content. If you want to edit the content of a Story that is used by a Case, you can mark the Story content as local content, and then share the new content as a new Story. The original Story is not changed, which is important if it is used in other places in the document.
In design-time, you can select the Story to used as a sample.
You can also select to create empty content for a specific Case that previously had a Story connected to it
For a Case that has the local content of the switch, you can specify if the content is inline or in a separate paragraph.
*
Example 51
You want the value of the Message age_category field to determine what Story to use. You add two Cases to a Switch:
a Case that specifies that if the language field value is young, the Story_young is used. The Case key is in this case young.
a Case that specifies if the language field value is mature, the Story_mature is used. The Case key is in this case mature.
You want a neutral story to be used if the language field is anything else but young or mature, so you add a default Case where you specify that Story_generic is used.
Click to enlarge
Figure 50
 
To add a Switch
1
Right-click in the Document, Page, or Story view and select Insert > Switch. The Data Selection dialog opens.
2
Select the field or variable to base the Switch on and click OK. A text area with a Switch and a Case is added to the document.
To add a Case
1
Right-click the Switch and select Switch > Add Case. The Key dialog opens.
2
Note:
To select a Story for a Case
1
2
3
To add a Default Case
Right-click the Switch and select Switch > Add Default Case. A default Case is added to the Switch.
To create local content from a Story used by a Case
1
2
Right-click and select Switch > Use local content. The Story content is copied as local content for the Case.
To edit local content in the Story view
1
2
Right-click and select Switch > Edit in Story View.
To share local content of a Case as a new Story
1
2
Right-click and select Switch > Share Story. A new Story is created with the local content.
To create empty content in a Case
1
2
Right-click and select Switch > Use Empty Local Content.
To select which Case key to use as the Switch sample
1
2
Right-click and select Switch > Use Key as Sample.
Note:
To make a Case the default Case
1
2
Right-click and select Switch > Make Case as Default.
*
OpenText StreamServe 5.6 Updated: 2013-03-01