To nest queries, assign them to child elements.
Procedure
- In Document Studio, open the Data Source Schema view.
- Drag an element from the Data Source Schema view
to the template element. When a query is dragged onto an
element that has parent element, the dragged query is checked whether
it can be run in the context of a parent element query. All the queries
that can serve as context are displayed in a Select Context window.
The list displays the ID and its textual representation.
- Select the query context from the list. Selecting
none for the context results in two unrelated nested queries.
- Click OK.
Example
The following example shows a nested query assigned to
a Rational® DOORS® template
element.
Paragraph DOORS 1 $1 Module/Object
Text
Module/Object/Object/Heading
Paragraph DOORS 1 $2 Module/Object/Attribute
Text
Module/Object/Attribute/Name
In this example, a query
Module/Object serves
as a context for
Module/Object/Attribute.
In
this example, setting the context for the second query to $1 produces
the following output:
- A set of paragraphs containing the heading of each object in the
module.
- A list of paragraphs with the attribute names for the current
object in query $1.
Setting the context for the second query to none produces
the following output:
- A set of paragraphs containing the heading of each object in the
module.
- A list of paragraphs with the attribute names for all the objects.
The following example shows the nested query assigned to a IBM® Rational Tau template
element.
The first query, model/root(Package),
is performed in the context of the Rational Tau model.
The second query, model/root(Package)/ownedMember,
is performed on each package returned by the first query.
If
the list of all classes from the top level packages in model is needed,
the query is
model/root(Package)/ownedMember(Class).
In this form, the output document no longer contains the name of each
package. A class list is built in the same way as it in the first
case. The query is split into its component queries, and each query
runs in the context defined by the previous queries:
Sub query |
Context |
Result |
model |
- |
the model |
model/root(Package) |
model |
list of packages |
ownedMember(Class) |
list of packages |
list of classes |
Each sub query is performed once for every element,
and the results of each execution are concatenated. These results
become the context for the next subquery, or the results list, if
the subquery is the last one.