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
- Assign queries.
- In Document Studio, open the Data Source
Schema view.
- Add elements to the template.
- 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.
- Set a limit to the query element.
Note: You
can process a subset of template elements by setting a limit to the
query elements.
- In Document Studio, select the template element that
contains the query.
- In the Properties view, select
the Data tab.
- 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.
- 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.
- Select the element that contains the query.
- In the Properties view, for the Recursive
Level property, enter how many levels deep the query is.
- 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.
- 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
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.xsdFor
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:
- Add the Project/Requirements/PRRequirement/Children/Relationship/RelatedReq query
to an element.
- Add values to the Recursive Level and Recursive Segments properties:
- Run the report to test.
On running the report, these queries
are included:
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 . 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 . 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 . The Data Source
Schema view opens and the query or attribute is highlighted.