XpressDox Help Center

Use Google To Find Help Fast, e.g. xpressdox choosefromlist


Press Getting Started in the XpressDox toolbar for basic template development
Watch the tutorial videos
View command help from list of commands
Press F1 for help on a command in the Command Editor
Email support@xpressdox.com for assistance

The ChooseFromDataset Command


The ChooseFromDataset Command

We have a ChooseFromRepeatingData command (which is the same as ChooseFromData, but is a more descriptive name), and a ChooseFromDataElements command. The ChooseFromDataset command combines the functionality of the other two, and adds some more flexibility.

The first argument is the name of the data element to be chosen. This is as per convention. The following arguments are in pairs – an XPATH to a particular choice, then an optional XPATH to the value to be shown in the drop down for that choice.

A simple example would be an interview which contains the names of the children in a family, a list of their friends, and the names of the parents. We would like to choose the name of the person most likely to be president. Here’s what the interview construction part of the template might look like:

«CaptureDataElements(Father,Mother)»
«CaptureInGrid(Child,Yes)»
«CaptureInGrid(Friend,Yes)»
«Heading(Child,|Children)»
«ForEach(Child)»
«Name»
«End()»
«Heading(Friend,|Friends)»
«ForEach(Friend)»
«Name»
«End()»
«ChooseFromDataset(President,Father,,Mother,,Child/Name,,Friend/Name)»
«President»

The items in the drop down would then be the Father’s name, the Mother’s name, followed by <each of the children’s names>, <each of the friend’s names>. When the user chooses an item in the drop-down, the value placed into President would be the corresponding value of the data elements Father, Mother, the chosen Child or the chosen Friend‘s name.

Look at what would happen if you replace the above ChooseFromDataset with the following:

«ChooseFromDataset(President,Father,'The Father',Mother,'The Mother','','CHILDREN and FRIENDS',(Child | Friend)/Name)»

This would display the text ‘The Father’ and ‘The Mother’ instead of the Father and Mother’s names (respectively), and put a “heading” between the Mother and the Child and Friend items. And yet the values chosen, and placed in the dataset, will be exactly as for the first example.

More Advanced Syntax

As with many of the XpressDox commands and functions, the power of XPATH is available to the template author. For example, the following command will achieve the same result as the first one:

«ChooseFromDataset(President,Father,'The Father',Mother,'The Mother','','CHILDREN and FRIENDS',(Child | Friend)/Name)»

Or, perhaps, you only want to present the children where the age is greater than 18 (which, obviously, would require capturing the Age inside the Child part of the interview):

«ChooseFromDataset(President,Father,'The Father',Mother,'The Mother','','CHILDREN and FRIENDS',Child[Age > 18]/Name,,Friend/Name)»