# Creating a Conditional Constraint Using the Constraints Tab

In Merging the Contents of Repeating Elements, both of the source documents (PriceQuote.xml and AvailQuote.xml) share the common element widgetId. A constraint (as a condition) can be added to the join that specifies if the widgetId of the availRequest element is equal to the widgetId of the priceRequest element the merged repeating element quoteResponse be returned.

When you create a structural link between a repeating element in the Design View, an XQuery for loop is generated to iterate through the repeating elements. Creating a constraint using the Where Clause Expression pane of the Constraints tab adds a where clause to the XQuery for loops which limits the target repeating elements which are returned during run time. The condition that makes up the where clause are evaluated for each iteration of the for loop.

Adding this constraint would change the resulting data as shown in Figure: Merging the Contents of Repeating Elements to the data shown in Figure: Using a Conditional Constraint to Merge Data.

Figure : Using a Conditional Constraint to Merge Data

For a step-by-step walk through of using the mapping functionality to create a join with a constraint, see Tutorial: Building Your First Data Transformation. Specifically, the join is created in Step 4: Mapping Repeating Elements—Creating a Join in the Tutorial: Building Your First Data Transformation.

In the next section an additional condition is added to the where clause. To learn more see Adding a Constraint With Multiple Conditions.