SystemWeaver's <Context> is made up of item groups, which can be created by using <AddParts> and/or <ItemGroup>. Each context need a starting point, which is the point at which you start filling the context with information. The starting point can be the currently selected item (referred to in the context definition as "main") and/or Parameters. After defining the starting point for a context, the item groups need to be created using the following tags:

  • <AddParts> which starts from an already existing group (owner group), main, or parameter and result in creating a new group or, in some cases, add to an existing group (defobj group)
  • <ItemGroup> which creates an item group using a path expression that starts from the context main or parameters.

In this article, we focus on <ItemGroup> and describe how it works, how to combine the use of <ItemGroup> with <AddParts>, and what the advantages and disadvantages are of using <ItemGroup>. We will also provide some example configurations.


  • SystemWeaver version R36 or later is required for the use of <ItemGroup> in <Context>
  • Familiar with the SystemWeaver Path Query Language

How ItemGroup works

<ItemGroup> can build context easily by creating item groups containing items of interest using a path expression (similar to how SystemWeaver <Variable> works). It can collect items from different parts of a structure and add them to a group in one go instead of using several <AddPart> tags. However, there are some advantages and disadvantages of using <ItemGroup> which are explained more in detail below. One use case for <ItemGroup> is when <AddPart> tags are used just to navigate through a structure to the items of interest, e.g., to collect requirements in a context group, where several <AddPart> tags are needed to handle the requirement structure (requirement groups and sub-groups). Another use case is to apply some filters to select a specific set of items to be added to a group.

The <ItemGroup> tag is used with two attributes: name and select.
name is the name for the group of items that the select query is linked to.
select specifies the path expression to be used when adding items to this ItemGroup.


<Context name="context1">
    <ItemGroup name="" select=""/>
    <ItemGroup name="" select=""/>
    <AddParts owner="" sid="" part="" defobj=""/>
    <AddParts owner="" sid="" part="" defobj=""/>       
Note: The <ItemGroup> tag should be added at the beginning of the <Context> definition (before <AddParts>).

How to Combine Use of ItemGroup and AddParts

One or more <ItemGroup> tags and one or more <AddPart> tags can be used together. Starting from an item group, you can go to another group using <AddPart>, and vice versa.  For example, the figure below shows how to go from group1 to group3 using <AddPart>, and also go from group3 to group2 using <AddPart>.

<Context name="context1">
    <ItemGroup name="group3" select="..."/>
    <AddParts owner="main" sid="SIDX" part="PartNameX" defobj="group1"/>   
    <AddParts owner="group1" sid="SIDY" part="PartNameY" defobj="+group3"/> 
    <AddParts owner="group1" sid="SIDZ" part="PartNameZ" defobj="group2"/> 
    <AddParts owner="group3" sid="SIDW" part="PartNameW" defobj="+group2"/> 

Advantages and Disadvantages of ItemGroup

There are several advantages of using <ItemGroup>.

  • When building a group using <ItemGroup>, it is possible to select the items of interest using the Path Query Language, which enables you to apply needed filters and conditions. For example:
<Context name="context1">
    <ItemGroup name="group3" select="/(IBIS|IIS|IBLC|IBOS|IDI|IRRS|IBRA|IRSI)[IsSID('RG')]"/>
  • You can reuse predefined variables that are defined outside the <Context>. For example:
<Variable name="requirements" as="[Item]" select="/(IBIS|IIS|IBLC|IBOS|IDI|IRRS|IBRA|IRSI)[IsSID('RG')]"/>

<Context name="context1">
    <ItemGroup name="group3" select="$requirements"/>
  • It enables the use of Context together with Template With Parameter. For example:
<ApplyTemplate name="t1">
    <WithParam name="p1" select="/FUPA/REDC/IBRA*/3SBH*"/>
    <WithParam name="p2" select="/DEPA/DEDS/IXRQ*/IXRR*"/>
    <WithParam name="p3" select="/DEPA/AIML/IRMM"/>

<Template name="t1">
    <Parameter name="p1" as="[Item]"/>
    <Parameter name="p2" as="[Item]"/> 
    <Parameter name="p3" as="[Item]"/>
    <Context name="context1">
        <ItemGroup name="leftRecruitmentGroup" select="$p1"/>
        <ItemGroup name="rightRecruitmentGroup" select="$p2"/>
        <ItemGroup name="mappingItems" select="$p3"/>
        <AddParts owner="mappingItems" sid="EXRE" part="primary" defobj="+leftRecruitmentGroup"/>
        <AddParts owner="mappingItems" sid="INRX" part="secondary" defobj="+rightRecruitmentGroup"/>
  • It shortens the context definition since you do not have to add <AddPart> tags that do not add any value to the context and whose only purpose is to navigate a structure to reach the item of interest. The example below shows how a context definition can be reduced from 14 lines (using only AddPart) to 7 lines (using ItemGroup and AddPart).

Using Only <AddPart>

<Context name="context1">
	<AddParts owner="main" sid="FUPA" part="Functions" defobj="Function"/>
	<AddParts owner="Function" sid="REDC" part="FunctionContainers" defobj="FunctionContainer"/>
	<AddParts owner="FunctionContainer" sid="IBRA" part="LeftRequirements" defobj="LeftRequirement"/>
	<AddParts owner="FunctionContainer" sid="3SBH" part="LeftRequirements" defobj="+LeftRequirement"/>
	<AddParts owner="main" sid="DEPA" part="Designs" defobj="Design"/>
	<AddParts owner="Design" sid="DEDS" part="DesignContainers" defobj="DesignContainer"/> 
	<AddParts owner="DesignContainer" sid="IXRQ" part="RightRequirements" defobj="RightRequirement"/>
	<AddParts owner="DesignContainer" sid="IXRR" part="RightRequirements" defobj="+RightRequirement"/>
	<AddParts owner="Design" sid="AIML" part="MappingItemContainers" defobj="MappingItemContainer"/>
	<AddParts owner="MappingItemContainer" sid="IRMM" part="MappingItems" defobj="MappingItem"/>
	<AddParts owner="MappingItem" sid="EXRE" part="MappingItemLeftReq" defobj="+LeftRequirement"/>
	<AddParts owner="MappingItem" sid="INRX" part="MappingItemRightReq" defobj="+RightRequirement"/>

Using <ItemGroup> and <AddPart>

<Context name="context1">
  <ItemGroup name="leftRecruitmentGroup" select="/FUPA/REDC/IBRA*/3SBH*"/>
  <ItemGroup name="rightRecruitmentGroup" select="/DEPA/DEDS/IXRQ*/IXRR*"/>
  <ItemGroup name="mappingItems" select="/DEPA/AIML/IRMM"/>
  <AddParts owner="mappingItems" sid="EXRE" part="primary" defobj="+leftRecruitmentGroup"/>
  <AddParts owner="mappingItems" sid="INRX" part="secondary" defobj="+rightRecruitmentGroup"/>

However, there is a limitation when using <ItemGroups> which is that you cannot go back within the select of the <ItemGroup>. If you need to go back within the selected items of a group, you must use <AddPart> instead of <ItemGroup>. The below example XML definition shows how to build a context using <AddPart> and <ItemGroup> to collect requirements and their signals dependency for a design function. The example meta model, context visualizer, and result are included for better understanding. 


Example Meta Model

Example Configuration

    <Context name="context1">
        <ItemGroup name="requirement" select="/ITFC/5IRR/DREC"/>
        <AddParts owner="main" sid="DERE" part="functionRequirement" defobj="+requirement"/>
        <AddParts owner="requirement" sid="SIGD" part="signalDependency" defobj="+signal"/>
        <AddParts owner="main" sid="ITFC" part="functionSWC" defobj="softwareComponent"/>
        <AddParts owner="softwareComponent" sid="ARPP" part="sendPort" defobj="+signal"/> 
        <AddParts owner="softwareComponent" sid="ARRP" part="ReceivePort" defobj="+signal"/>
    <ForEachInContext name="context1" group="requirement">
        <Text>- #{Name}</Text>
        <ContextGoForward part="signalDependency">
            <Text>     -Signal Dependency: #{Name}</Text>

Context Visualizer

To visualize the context, select it in the report configuration, right-click and select Show context visualizer

Example Result