<Report>
    
<!--Text styles and Paragraph styles --->
<!--Document uses a predefined text styles and paragraph styles, to change the predefined style use ParaStyle and FontStyle -->

  <ParaStyles>
    <ParaStyle name="TOC1"  alignment="left" spaceBefore="5"/>
    <ParaStyle name="TOC2"  alignment="left" spaceBefore="10"/>
    <ParaStyle name="TOC3"  alignment="left" spaceBefore="15"/>
    <ParaStyle name="TOC4"  alignment="left" spaceBefore="20"/> 
    <ParaStyle name="TOC5"  alignment="left" spaceBefore="25"/>
  </ParaStyles>
  <FontStyles>
    <FontStyle name="StyleXYZ"  font="Franklin Gothic Book" />
    <FontStyle name="Contents"  font="Franklin Gothic Book" style="bold" size="16"  />   
    <FontStyle name="Normal" font="Georgia" size="10" />
    <FontStyle name="Heading0" style="bold" font="Franklin Gothic Book" size="16"/>
    <FontStyle name="Heading1" style="bold" font="Franklin Gothic Book" size="16"/>
    <FontStyle name="Heading2" style="bold" font="Franklin Gothic Book" size="15"/>
    <FontStyle name="Heading3" style="bold" font="Franklin Gothic Book" size="14"/>
    <FontStyle name="Heading4" style="bold" font="Franklin Gothic Book" size="13"/> 
    <FontStyle name="Heading5" style="bold" font="Franklin Gothic Book" size="12"/>
    <FontStyle name="TOC1" style="bold" font="Georgia" size="10" color="Black" />
    <FontStyle name="TOC2" style="bold" font="Georgia" size="10" color="Black" />
    <FontStyle name="TOC3" style="bold" font="Georgia" size="10" color="Black" />
    <FontStyle name="TOC4" style="bold" font="Georgia" size="10" color="Black" />
    <FontStyle name="TOC5" style="bold" font="Georgia" size="10" color="Black" />
  </FontStyles>       

  <!--Adds a table of contents, max_level limits the number of levels in the table of contents-->
  <TableOfContents max_level="5" para="Normal" style="Normal" font="Normal" size="8"/>         
  <PageBreak/>        

  <ForEachPart type= "IRRS"> <!-- Report Section -->
    <DefObj> 
      <ApplyItemTemplates/> 
    </DefObj>
    <PageBreak/>
  </ForEachPart>    

  <ItemTemplate type = "NMOD"> <!-- Model Section -->    
    <ApplyTemplate name="AddTerms"/>
    <Section title ="#{Name}" font="StyleXYZ"> 
      <ForEachPart type = "IBRB"> <!-- Section Requirement -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart>
      <ForEachPart type = "IRSI"> <!-- Section Items -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart>
      <ForEachPart type = "ISSE"> <!-- Sub Sections -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart>
    </Section>      
    <PageBreak/> 
  </ItemTemplate>

  <ItemTemplate type = "SSSE"> <!-- Section -->    
    <ApplyTemplate name="AddTerms"/>
    <Section title = "#{Name}">
      <Description/>       
      <ForEachPart type = "IBRB"> <!-- Section Requirement -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart>
      <ForEachPart type = "IRSI"> <!-- Section Items -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart>
      <Choose> <!-- Insert reference list in the right Document section -->
        <When test="Name='Glossary'">
          <Text/>
          <ApplyTemplate name="AddGlossaryTable"/>
        </When>
        <When test="Name='Acronyms, Abbreviations, and Symbols'">
          <Text/>
          <ApplyTemplate name="AddAcronymsTable"/>
        </When>
        <When test="Name='Reference Documents'">
          <ApplyTemplate name="AddDocRefsTable"/>
        </When>
        <When test="Name='Release and Revision'">
          <ApplyTemplate name="PrintChangeLog"/>
        </When>
        <When test="Name='Release and revision'">
          <ApplyTemplate name="PrintChangeLog"/>
        </When>
        <Otherwise>
          <!-- No other cases supported -->
        </Otherwise>
      </Choose> 
      <ForEachPart type = "ISSE"> <!-- Sub Section -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart>
    </Section>  
  </ItemTemplate>

  <!-- Item Templates -->

  <ItemTemplate type = "BINA"> <!-- Real Allocation Target -->           
    <ApplyTemplate name="AddTerms"/>
    <ForEachPart type = "9RSW"> <!-- Components -->
      <DefObj>              
        <ApplyItemTemplates/>
      </DefObj>
    </ForEachPart>  
  </ItemTemplate>

  <ItemTemplate type = "5REQ"> <!-- Atomic components -->    
    <ApplyTemplate name="AddTerms"/>
    <Section title = "#{Name}">
      <Description/>       
      <ForEachPart type = "5IGR"> <!-- Requirement group -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart>
      <ForEachPart type = "IJRG"> <!-- Design Requirement -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart>
    </Section>  
  </ItemTemplate>

  <ItemTemplate type = "5E2G"> <!-- Requirement group -->
    <ApplyTemplate name="AddTerms"/>
    <Section title = "#{Name}">
      <Description/>            
      <ForEachPart type = "5IE2"> <!-- Requirement -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart>
      <ForEachPart type = "5SGR"> <!-- Sub group -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart> 
    </Section>  
  </ItemTemplate>

  <ItemTemplate type = "5GRO"> <!-- Design Requirement group -->
    <ApplyTemplate name="AddTerms"/> 
    <Section title = "#{Name}">
      <Description/>            
      <ForEachPart type = "5GRE"> <!-- Requirements -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart>
      <ForEachPart type = "5DSRG"> <!-- Sub group -->
        <DefObj>              
          <ApplyItemTemplates/>
        </DefObj>
      </ForEachPart>
    </Section>  
  </ItemTemplate>

  <!-- Filter to exclude the empty requirement's Rationale  -->

  <Filter name="F1"> 
    <AttributeValueEquals sid="5RTI" value=""/>
  </Filter>       

  <ItemTemplate type = "RQ"> <!-- Requirement -->
    <AddToChangeLog/>
    <ApplyTemplate name="AddTerms"/>      
    <Section title = "#{Name}">
      <Table>
        <Options>
          <CellBorderWidth>0</CellBorderWidth>
        </Options>
        <Header visible="false"/>
        <Columns>
          <TextColumn font="Italic" width="85">Requirement ID:  </TextColumn>
          <ItemAttributeColumn type="5RID" caption=""/>
          <TextColumn>version: #{VersionNumber}</TextColumn>
        </Columns>
        <Row/>
      </Table> 
      <!-- Add Requirement Rationalet-->
      <Choose>
        <When filter="F1"> 
          <AttributeTable exclude="5RTI,5RID,5COM"/>
        </When>
        <Otherwise>
          <AttributeTable exclude="5RID,5COM"/>
        </Otherwise>
      </Choose>
      <Text/>
      <Description/> 
    </Section>
  </ItemTemplate> 

  <!-- Other Templates, "utilities" -->
  <Template name="AddTerms"> 
    <ForEachPart type="IDR"> <!-- Description Reference -->
      <DefObj>
        <ApplyTemplate name="ClassifyTerms"/>
        <ForEachPart type="IDR"> <!--  No iteration, to avoid endless iteration, only two levels included -->
          <DefObj>
            <ApplyTemplate name="ClassifyTerms"/>
          </DefObj>
        </ForEachPart>
      </DefObj>
    </ForEachPart>
  </Template>
  <!--Checks if a term is an Acronym, a Glossary or a Document Reference--> 
  <Template name="ClassifyTerms">
    <Choose>
      <When test="SID='3PTMA'">
        <AddItemToListUnique name="Acronyms"/>
      </When>
      <When test="SID='3PTMT'">
        <AddItemToListUnique name="Definitions"/>
      </When>
      <When test="SID='5SSRP' or SID='SRD'">
        <AddItemToListUnique name="DocRefs"/>
      </When>
      <Otherwise>
        <!-- Ignore other Description References! -->
      </Otherwise>
    </Choose>  
  </Template>
  <!-- Prints Glossaries-->
  <Template name="AddGlossaryTable">
    <Table>
      <Header visible="false"/>
      <Options>
        <CellBorderWidth>0</CellBorderWidth>
      </Options>
      <Columns>
        <ItemNameColumn width="100" caption=""/>
        <DescriptionColumn width="auto" caption=""/>
      </Columns>
      <ForEachItemInList name="Definitions" sort="Name"> 
        <Row/>
      </ForEachItemInList>
    </Table>
  </Template>
  <!-- Prints Acronyms-->
  <Template name="AddAcronymsTable">
    <Table>
      <Header visible="false"/>
      <Options>
        <CellBorderWidth>0</CellBorderWidth>
      </Options>
      <Columns>
        <ItemNameColumn width="100" caption="" font="Bold"/>
        <DescriptionColumn width="auto" caption=""/>
      </Columns>
      <ForEachItemInList name="Acronyms" sort="Name">  
        <Row/>
      </ForEachItemInList>
    </Table>
  </Template>
  <!-- Prints Document References-->
  <Template name="AddDocRefsTable">
    <Table>
      <Header visible="false"/>
      <Options>
        <CellBorderWidth>0</CellBorderWidth>
      </Options>
      <Columns>
        <ItemNameColumn width="100" caption="" font="Bold"/>
        <DescriptionColumn width="auto" caption=""/>
      </Columns>
      <ForEachItemInList name="DocRefs" sort="Name">  
        <Row/>
      </ForEachItemInList>
    </Table>
  </Template>

  <!--Prints a change log of all items that are subject to change control. Type attribute can be used to filter the change types, which are new, updated and deleted-->
  <Template name="PrintChangeLog">
    <Section title="Change Log">
      <!--new: Lists items that have been added since the previous version-->
      <Section title="New requirements">
        <Table>
          <Columns>
            <ItemNameColumn caption="Name" width="370"/>
            <AttributeColumn caption="Req.ID" width="100" type="5RID" sum="false"/>  
          </Columns>
          <ForEachItemInChangeLog type="new">
            <Row/>
          </ForEachItemInChangeLog>
        </Table>
      </Section>
      <!-- updated: Lists items that have been updated since the previous version-->
      <Section title="Updated requirements">
        <ForEachItemInChangeLog type="updated">
          <DescriptionDiff/>
        </ForEachItemInChangeLog>
      </Section>
      <!--deleted: Lists items that have been deleted since the previous version-->
      <Section title="Deleted requirements">
        <Table>
          <Columns>
            <ItemNameColumn caption="Name" width="370"/>
            <AttributeColumn caption="Req.ID" width="100" type="5RID" sum="false"/>  
          </Columns>
          <ForEachItemInChangeLog type="deleted">
            <Row/>
          </ForEachItemInChangeLog>
        </Table>
      </Section>
    </Section>
  </Template>

  <!-- Template for Item, "catch" in case of missing template -->
  <ItemTemplate type="I">            
    <Log>ERROR!! ItemTemplate for #{Type.Name} #{Name} is missing. Check your Model, or report to your SystemWeaver admin. </Log>
    <Text>ERROR!! ItemTemplate for #{Type.Name} #{Name} is missing. Check your Model, or report to your SystemWeaver admin. </Text>
  </ItemTemplate>     

</Report>