Take the sample tables, ECTS_DEPTS and
ECTS_EMPLOYEES. Suppose you want to create an XML document that lists all the departments from
ECTS_DEPTS and, for each department, all its employees. You can do that with nested
FORALL statements in the TIBCO Object Service Broker rules language, like this:
In an XML document, you can perform that task with a child document. For the preceding example, define an XML document for the
ECTS_DEPTS table, which then becomes your parent document, and name it
PRIMER_DEPTS.
Earlier in this chapter, you created an XML document named PRIMER_EMPS to display a list of employees. Perform the following steps to reuse that document for selecting employees in one department by applying data- selection criteria:
Now add a few selection criteria to our child document, keeping in mind that you want to list only the employees in the department currently being processed. In the
PRIMER_DEPTS document definition under the Child Documents tab is an area in which to specify parameter values for the table, as appropriate, and any necessary data selection criteria. Those properties override the values that already exist in the child document. That is, you need not revise any of the properties of the child document that would change its function as a parent.
In this case, you do not need any parameter values because the ECTS_EMPLOYEES table is not parameterized. Your selection criterion is to list all the employees in the department currently being processed. Recall that the department number in both tables is in the field
DEPTNO. Simply apply the curly-bracket (
{}) notation to access the field in the
ECTS_DEPTS table to phrase the selection, as shown here:
Finally, to test the result, run PRIMER_DEPTS by choosing Run As from the short-cut menu for the selected
PRIMER_DEPTS item in the XML Documents view. Here is the output: