Assigning queries

A query defines what data is to be extracted from the data source. You can assign a query to a template element to define the data context for that element and its children.

About this task

A query is a path in the data source schema which is assigned to a template element to extract data. Template elements having queries are generated for each data element extracted from the data source.

Procedure

  1. Assigning Queries:
    1. In Document Studio, open the Schema view.
    2. Drag the element from the Schema view to the template element.
    After a query is assigned to a template element, you can use the attributes of the query type (the element dragged from the Schema view) anywhere in the template element and its child elements.
    Note: If you have version IBM® Rational® Publishing Engine 1.1.1.1 or later, you can process a subset of template elements by setting a limit to the query elements.
  2. Setting a limit to the query element:
    1. In Document Studio, select the template element that contains the query.
    2. In the Properties view, expand Data > Limit.
    3. Enter the number of objects from the data source that is to be used in the respective query. A value of 0 (zero) represents no limit set for the query.
  3. Assigning recurrent queries: You use data recursion when you want to extract all child requirements from a main source requirement in a schema.
    For example, if there is a schema like in the figure. You want to extract the list of SRRequirements (Software requirements). For each SRRequirement you want to extract all child requirements, for each child requirement you want to further extract its child requirements.
    In this context, you would create the following queries:
    • [$1] Project/Requirements/SRRequirement, for extracting the SRRequirements.
    • [$2] $1/Children/Relationship/Requierement, child requirements of each SRRequirement.
    • [$3] $2/Children/Relationship/Requirement, child requirements of each child requirement of each SRRequirement.
    IBM Rational Publishing Engine provides a mechanism to perform this requirement automatically. You need to construct only one query.
    1. Create Project/Requirements/SRRequirement/Children/Relationship/Requierement, [$2].
    2. Add the desired values in the Recursive Level and Recursive Segments. Recursive Level represents the depth of recursion for the query and Recursive Segments represents the number of repetitive segments from the query.
    You can set the recursion level as deep as you want. In this example, taking into account the existing information in the Data Source, you want to go 4 levels deep and the recursive segments value is 3. The segments that are added to construct the recursive query are Children/Relationship/Requierement.
    On running the report containing this template, the following queries are executed:
    • [$1] – Project/Requirements/SRRequirement/Children/Relationship/Requierement.
    • [$2] – $1/ Children/Relationship/Requierement.
    • [$3] - $2/Children/Relationship/Requierement.
    • [$4] – $3/Children/Relationship/Requierement.
    Note: You can see that the [$2] query has a parent context set. If you want to have recursion on a specific query for the moment it is mandatory to have that query in the context of a parent query.

Example

Queries in IBM Rational DOORS® starts with the root element (module), continues with its child element (Object), then with the object's child attribute. For example, Module.Object.Attribute.Name.

Assigning a query to a template element

Queries in IBM Rational Tau have a syntax similar to the XPath syntax. However, unlike XPath, Rational Publishing Engine query does not specify a filter; the filter and sort clauses are separate from the query. Each schema element, except the query, is defined through a Rational Tau native query. This query, which is expressed in OCL, fetches Rational Tau data. For example, the root element under the model element model.rootResource has the GetModelRoots() Tau query attached to it.


Feedback