Assigning queries

A query defines what data is extracted from the data source and takes the form of a path in the data source schema. You can assign a query to a template element to define the data context for that element and its children.

About this task

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

Queries in IBM Rational Tau have a syntax similar to the XPath syntax. However, unlike XPath, the 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() Rational Tau query attached to it.

Procedure

  1. Assign queries.
    1. In Document Studio, open the Data Source Schema view.
    2. Add elements to the template.
    3. Drag the queries from the Data Source Schema view into the elements.
    A query is assigned to a template element, you can use the attributes of the query type, the element dragged from the Data Source Schema view, anywhere in the template element and its child elements.
  2. Set a limit to the query element.
    Note: You can process a subset of template elements by setting a limit to the query elements.
    1. In Document Studio, select the template element that contains the query.
    2. In the Properties view, select the Data tab.
    3. For the Limit property, enter the number of objects from the data source to be used in the respective query. A value of 0 (zero) represents no limit set for the query.
  3. Assign recurrent properties to the queries. You use data recursion to extract all of the child requirements from a main source requirement in a schema.
    1. Select the element that contains the query.
    2. In the Properties view, for the Recursive Level property, enter how many levels deep the query is.
    3. For the Recursive Segments property, enter how many times the segments repeat in the query.
    See the example below about recursive levels and recursive segments.
  4. Save your changes.

Results

When you apply a query to an element, there are three visual indicators that display in blue by default in the template content editor:
  • The data source schema name
  • The context displayed with a dollar sign ($)
  • The query name
Cell element with a query applied
Tip: When clearing information from queries, Clean references and Clear data work differently. Clean references is only available when you select an element that has a query. Clean references removes all of the queries, attributes, filters, sorts, and conditions on the element you have selected and its child elements, if they also have queries or attributes assigned to them. Clear data removes all queries, attributes, filters, sorts and conditions on the element you have selected and its child elements. Master pages, styles, and formatting properties are not removed.

Example: Recursive level and recursive segments

You can see a list of software requirements by using the PRRequirement query in the IBM Rational RequisitePro® schema available to you in the samples installed with Rational Publishing Engine: %RPE_HOME%\source\XML\examples\RequisitePro.xsd

For each PRRequirement, you can extract all of the child requirements, and for each child requirement, extract its child requirements without adding each query to your template.

Instead of adding each of these following queries:
  • [$1] Project/Requirements/PRRequirement to extract the PRRequirements.
  • [$2] $1/Children/Relationship/RelatedReq to extract child requirements of each PRRequirement.
  • [$3] $2/Children/Relationship/RelatedReq to extract child requirements of each child requirement of each PRRequirement.
You can construct one query for these requirements automatically:
  1. Add the Project/Requirements/PRRequirement/Children/Relationship/RelatedReq query to an element.
  2. Add values to the Recursive Level and Recursive Segments properties:
    • For the Recursive Level property, enter 4.

      Recursive Level represents how many levels deep the query is. If you enter a value of one or higher, you must also set a value of one or higher for the Recursive Segments property.

    • For the Recursive Segments property, enter 3.
      Recursive Segments represents how many times the segments repeat in the query. The segments in this example are Children/Relationship/RelatedReq.
      Note: The number entered for the Recursive Segments property cannot be higher than the number of segments that the query contains. The parent query is not included as a segment.
  3. Run the report to test.
    On running the report, these queries are included:
    • [$1] – Project/Requirements/PRRequirement/Children/Relationship/RelatedReq
      Note: The first query must include the full context for the query.
    • [$2] – $1/ Children/Relationship/RelatedReq
    • [$3] - $2/Children/Relationship/RelatedReq
    • [$4] – $3/Children/Relationship/RelatedReq
    If you find that The number entered for the Recursive Segments property is higher than the number of segments that the query contains, you can use one of these two options to resolve the issue:
    • Select the element that has the Recursive Segments property applied. In the Properties view, select the Data tab and decrease the value for the recursive segments property.
    • You can also redesign the query to start from a different parent query. If your Recursive Segments value is one segment too high, create a container element and add a query that is one level higher than the parent query of the existing element. Then move the existing element into the container element.

What to do next

Tip: You can search for a list of queries and attributes by right-clicking an element and selecting Search > Data references in element. The Search view opens and a list of queries and attributes displays. You can double-click a query or attribute in the results to edit its content.

You can search for a list of variable assignments, attributes, and queries used in an element by right-clicking an element and selecting Search > All references in element. The Search view opens and a list displays. You can double-click an item in the results to edit it.

You can locate a query or attribute in the Data Source Schemas view from the element it is applied to by right-clicking an element and selecting Search > Go to schema. The Data Source Schema view opens and the query or attribute is highlighted.


Feedback