Query and Walk Functions
In a report recipe, you would use the query and walk functions whenever the scope of the report you are creating must include not only items returned in the original query but also items related to those returned in the query. For example, you would want to use walk when reporting on the contents of a document or any item hierarchy. You can also specify more than one relationship to walk.
The following are examples of syntax and the results:
• Query[((field[ID]=<%<%builtin ID%>%>)or(walk[<%builtin Contained By%>]<%<%builtin ID%>%>))]
Returns the current item (field[ID]) plus all items obtained by walking up the tree starting from the current item.
• Query[((field[ID]=<%<%builtin ID%>%>)or(walk[<%builtin Contains%>]<%Relationship<%builtin ID%>%>))]
Returns the current item plus all items obtained by walking down the tree starting from the item related to the current item (inside a relationship tag).
• Query[((walk[<%builtin Contained By%>]<%<%builtin ID%>%>)and(item.segment))]
Returns the segment items obtained by walking up the tree.
• Query[((item.node)and((field[ID]=<%<%builtin ID%>%>)or(walk[<%builtin Contained By%>]<%<%builtin ID%>%>)))]
Returns all nodes, including the current one, and any obtained by walking down the tree starting from the current item.
Representing Documents in Reports
walkDocOrderedQuery[(walkdocordered[<%<%builtin ID%>%>])]%>
Returns the document contents of a document specified by ID. The contents are returned in the order they appear in the Document view.
Specify the recurseinclude flag for the walkDocOrdered query to recurse into included documents:
walkDocOrderedQuery[(walkdocordered[<%<%builtin ID%>%>]recurseinclude)]%>
Filters can only be applied by updating the report recipe with a filter tag. Filters applied within the view from which the report was run are not applied in the generated report. The Section field cannot be used for filtering.
For example:
<%beginrelationshipsdetail Query[(walkdocordered[<%<%builtin ID%>%>]recurseinclude)]%>
<%filter%>(field[Category] = “Heading”)<%endfilter%>"
<% Relationship <%virtual Section%>%>
<%Relationship <%builtin Category%>%>
<%Relationship Text%>
<%Relationship <%builtin Document ID%>%>
<%endrelationshipsdetail%>
Returning Details on Items Related to Document Contents
Use nested relationship tags to return details on items related to document contents.
For example:
<%beginrelationshipsdetailL2 Query[(walkdocordered[<%Relationship <%builtin ID%>%>]recurseinclude)]%>
<%RelationshipL2 <%virtual Section%>%>
<%RelationshipL2 <%builtin Category%>%>
<%RelationshipL2 Text%>
<%RelationshipL2 <%builtin ID%>%>
<%RelationshipL2 <%builtin Document ID%>%>
<%beginrelationshipsdetailL3 Validated By%>
<%RelationshipL3 <%builtin ID%>%>
<%endrelationshipsdetailL3%>
<%endrelationshipsdetailL2%>
Including Section in Reports
To include section numbers in the report, use the <%virtual section%> tag in combination with other relationship tags and the walkDocOrdered query clause.
For example, to generate a report containing Section, Category, Text, and Document ID values, include the following syntax in the report recipe:
…
<%begindetail%>
<%beginrelationshipsdetail
Query[(walkdocordered[<%<%builtin ID%>%>]recurseinclude)]%>
<%Relationship <%virtual Section%>%>
<%Relationship <%builtin Category%>%>
<%Relationship Text%>
<%Relationship <%builtin Document ID%>%>
<%endrelationshipsdetail%>
<%enddetail%>
…
Known Limitations
• The section numbers will only be correct for the document if the walkDocOrdered query clause is not combined with any other clauses.