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.

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, Clear queries and Clear all work differently. Clear queries is only available when you select an element that has a query. Clear all 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. Master pages, styles, and formatting properties are not removed.

Example: Recursive level and recursive segments

For each parent query, 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] Query1/Query2/Query3 to extract the Query3.
  • [$2] $1/Query4/Query5/Query6 to extract child requirements of each Query3.
  • [$3] $2/Query4/Query5/Query6 to extract child requirements of each child requirement of each Query3.
You can construct one query for these requirements automatically:
  1. Add the Query1/Query2/Query3/Query4/Query5/Query6 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 Query4/Query5/Query6.
      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] – Query1/Query2/Query3/Query4/Query5/Query6
      Note: The first query must include the full context for the query.
    • [$2] – $1/Query4/Query5/Query6
    • [$3] - $2/Query4/Query5/Query6
    • [$4] – $3/Query4/Query5/Query6
    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