The Context tags enable you to follow parts forward and backward through a context using various navigation tags. This article provides some navigation examples using available tags. All contextual "go forward/back" tags must be enclosed by the ForEachInContext tag.


Prerequisites


Example Context

<Report>
  <Context name="architectureTop">
    <AddParts owner="main" sid="3EFL" part="archToE2EList" defobj="E2EList"/>
    <AddParts owner="E2EList" sid="3PEN" part="E2EListToE2E" defobj="E2Es"/>
  </Context>
...
</Report>

Traverse Backwards for Parts in Context Tree

The <ContextGoBackToPart> tag is used to traverse backward in the context tree, following the part-group (predefined in <context>) and specified by part="". This tag results in a list of parts as opposed to items.



....

  <Context name="architectureTop">

    ...

  </Context>  

  

  <ForEachInContext name="architectureTop" group="E2Es">


    <ContextGoBackToPart part="E2EListToE2E">         

         <Text>#{Name}</Text>                                          

    </ContextGoBackToPart>                                            


  </ForEachInContext>   

....


Traverse Backwards for Items in Context Tree

The <ContextGoBack> tag is used to traverse backward in the context tree, following the part-group (predefined in <context>) and specified by part="". This tag is the same as <ContextGoBackToPart> except that it results in a list of items as opposed to parts.



....

  <Context name="architectureTop">

    ...

  </Context>  

  

  <ForEachInContext name="architectureTop" group="E2Es">


    <ContextGoBack part="E2EListToE2E">                 

         <Text>#{Name}</Text>                                    

    </ContextGoBack>                                                    


  </ForEachInContext>   

....


Traverse Forward/Down in Context Tree

To move forward in the context tree, use <ContextGoForward> (for items) and <ContextGoForwardToPart> (for parts). The principle is the same here as for ContextGoBack and ContextGoBackToPart tags, except that you move forward/down in the context tree instead of backwards.


Tip: To traverse from the part, resulting from <ContextGoForwardToPart>, to the item (defobj), apply <ContextGoForward>.


Example 


Result:
Prints the name of all reference parts and reference items from sections in the document.

  • My Reference Part Name
  • My Reference



Note: The "+" operator will add items to the same group by a union operation. See Combining Context Item Groups.


Using the Path Query Language

It's also possible to traverse a context using the Path Query Language. This is done by noting "Context:" at the start of the path expression in your select to indicate that a context is being traversed.

<ForEach select=”Context:/PART1/PART2/back::PART5” .........>


Path expression allows for multiple steps on same row and also conditions along the way, by use of []. 


What's Next?

For a complete list of navigation tags, see SystemWeaver Contexts in the application Help.