Example: Combining Two Data Points

Top Previous Topic Next Topic  Print this topic

In this example, we aim to combine two data points from our data source using a common XPath Function called "concatenate". This function is used to combine multiple strings and, in this case, will concatenate the first name and the last name. The result will be a single full name, with the last name displayed first.

 

1. In the Create Expression Dialog, we first want to identify the function by selecting the Add a function option and choosing "concat()" from the drop-down menu.

 

concat1Figure 1: The concat() function is selected.

concat2

Figure 2: The concat() function is placed in the Expression Box.

 

2. Next, we will need to add the different string arguments that we want to combine, one at a time. Notice that we can extend the number of arguments for this functions to as many as required. Here we will select an item in the Data Tree, and choose Insert the selected path from Data Tree to add the path for that attribute in the Expression text box. We will start with the last name, so it will be displayed first.

 

3. We will now repeat this process including a string manually typed in order to add a comma and a space between the last and the first name attributes. In addition, we will add the "first-name" attribute by following the instructions from step two.

concat4

 

Figure 3: The Expression now contains all the string to be concatenated.

 

4. After designing the Expression, we will need to select Save to insert the Field into the document template. You will notice the field will be present in the Design Surface. It is recommended that you preview your output to ensure that the expression is evaluating as you intended it to. In Figure 6 you can see that the expression evaluates successfully combining the last name with a comma and a space, and then the first name.

 

concat_field

Figure 5: The field is inserted into the Design Surface.

 

 

concat_fieldresult

Figure 5: The output reveals the field is evaluated as intended.