Introduction

RIF and ReqIf are standard interchange formats for requirements specifications. They can be used, for example, to facilitate the exchange of requirements between suppliers and OEMs and are supported by several industrial tools. ReqIf files are XML files that have the following structure:

  1. Header: Contains information related to the author, a title, and the version of the XML document.
  2. Datatypes: Specifies the basic data types used, e.g., Integer, Real, Date, String, plain text, formatted text in XHTML
  3. Specification types: Specifies types of information that will be of interest in the exported RIF. In our case, requirements and requirements sections with their titles, descriptions, and relevant attributes.
  4. Specification objects: A list with all objects and their descriptions.
  5. Specification hierarchy: The structure of objects.


SystemWeaver builds on a configurable meta model where the information can be tailored to fit the process and methods that a company uses. With regards to ReqIF, this means that every customer configures their own exports based on the data that they have. This article describes how you can export to ReqIF files using the built-in XML generator in SystemWeaver. The example provided below uses the test server and Script Language Training sqlite training database.  


Prerequisites


Configuring the XML

We generate the ReqIf files using the configurable XML language in SystemWeaver. 

  1. Open the main document (Document 1, ID: x040000000000002A) in the test database. As you can see, the document contains a number of sections and requirements in a layered structure.

  2. In the View drop-down menu, select XMLs > Sandbox to create a new configurable XML. An XML example is provided at the bottom of this article and demonstrates how we traverse the data to create the ReqIf file.

  3. In the top part of the file, create a context for the document and the contained sections and requirements <Context>. 

  4. Then, add templates to create the header (CreateHeader) and the data types (CreateDataTypes). We recommend that you copy and paste these two templates as they are used in any database.

  5. The remaining templates shown in the example are concerned with creating specification types (CreateSpecObjectType) and specification objects. For specification objects, we use the templates SPEC-OBJECTS and CreateSpecObjectAttributes (the latter to create attributes for specification objects). To create the specification hierarchy, the templates CreateSpecificationHierarchy, SPEC-HIERARCHY-IRRS, and SPEC-HIERARCHY-IRSI are used.

  6. The last lines of the XML, use<ApplyTemplate> tags to call the different templates you have named and create the remaining elements required by the XML.


Viewing and Exporting

You can view the XML that you have created by switching to the View tab and can save the ReqIf file by using the Save as… button.



 Then, you can import it to other requirements management tools. For our example, the imported data can look as shown below:



Example XML: 

<XDocument name="REQ-IF">
  <XDefaultNamespace uri="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd"/>
  <XAttribute name="xmlns:reqif" value="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd"/>
  <XAttribute name="xmlns:reqif-common" value="http://www.prostep.org/reqif"/>
  <XAttribute name="xmlns:reqif-xhtml" value="http://www.w3.org/1999/xhtml"/>
  <XAttribute name="xmlns:xsi" value="http://www.w3.org/2001/XMLSchema-instance"/>
  <XAttribute name="xmlns:xhtml" value="http://www.w3.org/1999/xhtml"/>
  <XAttribute name="xsi:schemaLocation" value="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd reqif.xsd"/>
  <Options>
    <Suffix>reqif</Suffix>
  </Options>
  <Context name="SSRP">
    <AddParts owner="main" sid="IRRS" part="Section" defobj="+Sections"/>
    <AddParts owner="Sections" sid="ISSE" part="Section" defobj="+Sections"/>
    <AddParts owner="Sections" sid="IRSI" part="SectionItem" defobj="+Reqs"/>
  </Context>

  <Template name="CreateHeader">
    <XElement name="THE-HEADER">
      <XElement name="REQ-IF-HEADER">
        <XAttribute name="IDENTIFIER" value="RootItem_#{Handle}"/>
        <XElement name="CREATION-TIME">
          <Text>#{?Now.Format('utc')}</Text>
        </XElement>
        <XElement name="REQ-IF-TOOL-ID">
          <Text>SystemWeaver</Text>
        </XElement>
        <XElement name="REQ-IF-VERSION">
          <Text>1.0</Text>
        </XElement>
        <XElement name="SOURCE-TOOL-ID">
          <Text>SystemWeaver</Text>
        </XElement>
        <XElement name="TITLE">
          <Text>Export of: #{Name} #{Version} #{Handle}</Text>
        </XElement>
      </XElement>
    </XElement>
  </Template>
  <Template name="CreateDataTypes">
    <XElement name="DATATYPES">
      <XElement name="DATATYPE-DEFINITION-INTEGER">
        <XAttribute name="IDENTIFIER" value="ID_SW_IntegerType"/>
        <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
        <XAttribute name="LONG-NAME" value="Integer"/>
        <XAttribute name="MAX" value="2147483647"/>
        <XAttribute name="MIN" value="-2147483648"/>
      </XElement>
      <XElement name="DATATYPE-DEFINITION-REAL">
        <XAttribute name="IDENTIFIER" value="ID_SW_FloatType"/>
        <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
        <XAttribute name="LONG-NAME" value="Float"/>
        <XAttribute name="MAX" value="3.4028e+38"/>
        <XAttribute name="MIN" value="-3.4028e+38"/>
        <XAttribute name="ACCURACY" value="9"/>
      </XElement>
      <XElement name="DATATYPE-DEFINITION-DATE">
        <XAttribute name="IDENTIFIER" value="ID_SW_DateType"/>
        <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
        <XAttribute name="LONG-NAME" value="Date"/>
      </XElement>
      <XElement name="DATATYPE-DEFINITION-STRING">
        <XAttribute name="IDENTIFIER" value="ID_SW_StringType"/>
        <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
        <XAttribute name="LONG-NAME" value="String"/>
        <XAttribute name="MAX-LENGTH" value="1028"/>
      </XElement>
      <XElement name="DATATYPE-DEFINITION-XHTML">
        <XAttribute name="IDENTIFIER" value="ID_SW_XhtmlTextType"/>
        <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
        <XAttribute name="LONG-NAME" value="Plain text"/>
      </XElement>
      <XElement name="DATATYPE-DEFINITION-XHTML">
        <XAttribute name="IDENTIFIER" value="ID_SW_XhtmlFormatType"/>
        <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
        <XAttribute name="LONG-NAME" value="Formatted text"/>
      </XElement>
    </XElement>
  </Template>
  <Template name="CreateSpecObjectType">
    <!--Parameters-->
    <Parameter name="itemType" as="String"/>
    <Parameter name="itemName" as="String"/>
    <!--/Parameters-->
    <XElement name="SPEC-OBJECT-TYPE">
      <XAttribute name="IDENTIFIER" value="#{?$itemType}"/>
      <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
      <XAttribute name="LONG-NAME" value="#{?$itemName}"/>
      <XElement name="SPEC-ATTRIBUTES">
        <XElement name="ATTRIBUTE-DEFINITION-XHTML">
          <XAttribute name="IDENTIFIER" value="#{?$itemType}.ObjectText"/>
          <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
          <XAttribute name="LONG-NAME" value="Object Text"/>
          <XElement name="TYPE">
            <XElement name="DATATYPE-DEFINITION-XHTML-REF">
              <Text>ID_SW_XhtmlFormatType</Text>
            </XElement>
          </XElement>
        </XElement>
        <XElement name="ATTRIBUTE-DEFINITION-STRING">
          <XAttribute name="IDENTIFIER" value="#{?$itemType}.ObjectHeading"/>
          <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
          <XAttribute name="LONG-NAME" value="Object Heading"/>
          <XElement name="TYPE">
            <XElement name="DATATYPE-DEFINITION-STRING-REF">
              <Text>ID_SW_StringType</Text>
            </XElement>
          </XElement>
        </XElement>
        <XElement name="ATTRIBUTE-DEFINITION-STRING">
          <XAttribute name="IDENTIFIER" value="#{?$itemType}.Status"/>
          <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
          <XAttribute name="LONG-NAME" value="Status"/>
          <XElement name="TYPE">
            <XElement name="DATATYPE-DEFINITION-STRING-REF">
              <Text>ID_SW_StringType</Text>
            </XElement>
          </XElement>
        </XElement>
        <XElement name="ATTRIBUTE-DEFINITION-STRING">
          <XAttribute name="IDENTIFIER" value="#{?$itemType}.VersionNumber"/>
          <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
          <XAttribute name="LONG-NAME" value="VersionNumber"/>
          <XElement name="TYPE">
            <XElement name="DATATYPE-DEFINITION-STRING-REF">
              <Text>ID_SW_StringType</Text>
            </XElement>
          </XElement>
        </XElement>
        <XElement name="ATTRIBUTE-DEFINITION-STRING">
          <XAttribute name="IDENTIFIER" value="#{?$itemType}.VersionText"/>
          <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
          <XAttribute name="LONG-NAME" value="VersionText"/>
          <XElement name="TYPE">
            <XElement name="DATATYPE-DEFINITION-STRING-REF">
              <Text>ID_SW_StringType</Text>
            </XElement>
          </XElement>
        </XElement>
        <XElement name="ATTRIBUTE-DEFINITION-STRING">
          <XAttribute name="IDENTIFIER" value="#{?$itemType}.VersionID"/>
          <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
          <XAttribute name="LONG-NAME" value="VersionID"/>
          <XElement name="TYPE">
            <XElement name="DATATYPE-DEFINITION-STRING-REF">
              <Text>ID_SW_StringType</Text>
            </XElement>
          </XElement>
        </XElement>

        <If test="$itemType = 'X_RQ'">
          <XElement name="ATTRIBUTE-DEFINITION-INTEGER">
            <XAttribute name="IDENTIFIER" value="#{?$itemType}.Priority"/>
            <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
            <XAttribute name="LONG-NAME" value="Priority"/>
            <XElement name="TYPE">
              <XElement name="DATATYPE-DEFINITION-INTEGER-REF">
                <Text>ID_SW_IntegerType</Text>
              </XElement>
            </XElement>
          </XElement>

          <XElement name="ATTRIBUTE-DEFINITION-STRING">
            <XAttribute name="IDENTIFIER" value="#{?$itemType}.VerificationMethod"/>
            <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
            <XAttribute name="LONG-NAME" value="VerificationMethod"/>
            <XElement name="TYPE">
              <XElement name="DATATYPE-DEFINITION-STRING-REF">
                <Text>ID_SW_StringType</Text>
              </XElement>
            </XElement>
          </XElement>
        </If>
      </XElement>
    </XElement>
  </Template>
  <Template name="CreateSpecObjectAttributes">
    <XElement name="ATTRIBUTE-VALUE-XHTML">
      <XElement name="THE-VALUE">
        <XElement name="reqif-xhtml:div">
          <Description format="reqif" prefix="reqif-xhtml"/>
        </XElement>
      </XElement>
      <XElement name="DEFINITION">
        <XElement name="ATTRIBUTE-DEFINITION-XHTML-REF">
          <Text>X_#{Type.SID}.ObjectText</Text>
        </XElement>
      </XElement>
    </XElement>
    <XElement name="ATTRIBUTE-VALUE-STRING">
      <XAttribute name="THE-VALUE" value="#{Name}"/>
      <XElement name="DEFINITION">
        <XElement name="ATTRIBUTE-DEFINITION-STRING-REF">
          <Text>X_#{Type.SID}.ObjectHeading</Text>
        </XElement>
      </XElement>
    </XElement>
    <XElement name="ATTRIBUTE-VALUE-STRING">
      <XAttribute name="THE-VALUE" value="#{Handle}"/>
      <XElement name="DEFINITION">
        <XElement name="ATTRIBUTE-DEFINITION-STRING-REF">
          <Text>X_#{Type.SID}.VersionID</Text>
        </XElement>
      </XElement>
    </XElement>
    <XElement name="ATTRIBUTE-VALUE-STRING">
      <XAttribute name="THE-VALUE" value="#{Status}"/>
      <XElement name="DEFINITION">
        <XElement name="ATTRIBUTE-DEFINITION-STRING-REF">
          <Text>X_#{Type.SID}.Status</Text>
        </XElement>
      </XElement>
    </XElement>
    <XElement name="ATTRIBUTE-VALUE-STRING">
      <XAttribute name="THE-VALUE" value="#{VersionNumber}"/>
      <XElement name="DEFINITION">
        <XElement name="ATTRIBUTE-DEFINITION-STRING-REF">
          <Text>X_#{Type.SID}.VersionNumber</Text>
        </XElement>
      </XElement>
    </XElement>
    <XElement name="ATTRIBUTE-VALUE-STRING">
      <XAttribute name="THE-VALUE" value="#{VersionText}"/>
      <XElement name="DEFINITION">
        <XElement name="ATTRIBUTE-DEFINITION-STRING-REF">
          <Text>X_#{Type.SID}.VersionText</Text>
        </XElement>
      </XElement>
    </XElement>
    <!--Requirements have two special attributes: Priority and VerificationMethod-->
    <If test="Type.SID = 'RQ'">
      <XElement name="ATTRIBUTE-VALUE-INTEGER">
        <XAttribute name="THE-VALUE" value="#{Attribute:PRIO}"/>
        <XElement name="DEFINITION">
          <XElement name="ATTRIBUTE-DEFINITION-INTEGER-REF">
            <Text>X_#{Type.SID}.Priority</Text>
          </XElement> 
        </XElement>
      </XElement>
      <XElement name="ATTRIBUTE-VALUE-STRING">
        <XAttribute name="THE-VALUE" value="#{Attribute:ABVM}"/>
        <XElement name="DEFINITION">
          <XElement name="ATTRIBUTE-DEFINITION-STRING-REF">
            <Text>X_#{Type.SID}.VerificationMethod</Text>
          </XElement>
        </XElement>
      </XElement>
    </If>
  </Template>
  <Template name="SPEC-OBJECTS">
    <XElement name="SPEC-OBJECTS">
      <ForEachInContext name="SSRP" group="main">
        <ForEach select="Context:/Section*/SectionItem*">
          <XElement name="SPEC-OBJECT">
            <XAttribute name="IDENTIFIER" value="#{Handle}"/>
            <XAttribute name="LAST-CHANGE" value="#{?LastChanged.Format('utc')}"/>
            <XAttribute name="LONG-NAME" value="#{Name}"/>
            <XElement name="VALUES">
              <ApplyTemplate name="CreateSpecObjectAttributes"/>
            </XElement>
            <XElement name="TYPE">
              <XElement name="SPEC-OBJECT-TYPE-REF">
                <Text>X_#{Type.SID}</Text>
              </XElement>
            </XElement>
          </XElement>
        </ForEach>
      </ForEachInContext>
    </XElement>
  </Template>

  <Template name="CreateSpecificationHierarchy">
    <XElement name="SPECIFICATIONS">
      <XElement name="SPECIFICATION">
        <XAttribute name="IDENTIFIER" value="SPEC_#{Handle}"/>
        <XAttribute name="LAST-CHANGE" value="2015-03-31T16:33:20+02:00"/>
        <XAttribute name="LONG-NAME" value="#{Name}"/>
        <XElement name="TYPE">
          <XElement name="SPECIFICATION-TYPE-REF">
            <Text>TopType</Text>
          </XElement>
        </XElement>
        <XElement name="CHILDREN">
          <ForEachPart type="IRRS">
            <ApplyTemplate name="SPEC-HIERARCHY-IRRS"/>
          </ForEachPart>
        </XElement>
      </XElement>
    </XElement>
  </Template>
  <Template name="SPEC-HIERARCHY-IRRS">
    <XElement name="SPEC-HIERARCHY">
      <XElement name="IDENTIFIER">
        <Text>#{Handle}</Text>
      </XElement>
      <XElement name="OBJECT">
        <XElement name="SPEC-OBJECT-REF">
          <Text>#{DefObj.Handle}</Text>
        </XElement>
      </XElement>
      <XElement name="LAST-CHANGE">
        <Text>#{?Now.Format('utc')}</Text>
      </XElement>
      <XElement name="LONG-NAME">
        <Text>#{Name}</Text>
      </XElement>
      <DefObj>
        <ForEachPart type="ISSE">
          <XElement name="CHILDREN">
            <ApplyTemplate name="SPEC-HIERARCHY-IRRS"/>
          </XElement>
        </ForEachPart>
        <ForEachPart type="IRSI">
          <XElement name="CHILDREN">
            <ApplyTemplate name="SPEC-HIERARCHY-IRSI"/>
          </XElement>
        </ForEachPart>
      </DefObj>
    </XElement>
  </Template>
  <Template name="SPEC-HIERARCHY-IRSI">
    <XElement name="SPEC-HIERARCHY">
      <XElement name="IDENTIFIER">
        <Text>#{Handle}</Text>
      </XElement>
      <XElement name="OBJECT">
        <XElement name="SPEC-OBJECT-REF">
          <Text>#{DefObj.Handle}</Text>
        </XElement>
      </XElement>
      <XElement name="LAST-CHANGE">
        <Text>#{?Now.Format('utc')}</Text>
      </XElement>
      <XElement name="LONG-NAME">
        <Text>#{Name}</Text>
      </XElement>
    </XElement>
  </Template>

  <ApplyTemplate name="CreateHeader"/>
  <XElement name="CORE-CONTENT">
    <XElement name="REQ-IF-CONTENT">
      <ApplyTemplate name="CreateDataTypes"/>
      <XElement name="SPEC-TYPES">
        <ApplyTemplate name="CreateSpecObjectType">
          <WithParam name="itemType" select="'X_SSRP'"/>
          <WithParam name="itemName" select="'Document'"/>
        </ApplyTemplate>
        <ApplyTemplate name="CreateSpecObjectType">
          <WithParam name="itemType" select="'X_SSSE'"/>
          <WithParam name="itemName" select="'Section'"/>
        </ApplyTemplate>
        <ApplyTemplate name="CreateSpecObjectType">
          <WithParam name="itemType" select="'X_RQ'"/>
          <WithParam name="itemName" select="'Requirement'"/>
        </ApplyTemplate>
        <XElement name="SPECIFICATION-TYPE">
          <XAttribute name="IDENTIFIER" value="TopType"/>
          <XAttribute name="LAST-CHANGE" value="2015-03-25T15:55:00+01:00"/>
          <XAttribute name="LONG-NAME" value="#{Name}"/>
          <XElement name="SPEC-ATTRIBUTES"/>
        </XElement>
      </XElement>
      <ApplyTemplate name="SPEC-OBJECTS"/>
      <ApplyTemplate name="CreateSpecificationHierarchy"/>
    </XElement>
  </XElement>
</XDocument>



Note: With regards to ReqIF imports, we support mapping of the types in a ReqIF file to types in a SystemWeaver installation, including support for incremental imports that are built-in to the ReqIF standard.


Things to Consider

 Below are points to be aware of when exporting to ReqIF and importing into another system.

  • ReqIF is for the export of requirements (and requirements structure) only. It does not export other items, such as components, ports, etc. 
  • Similarly, a generated document/PDF of a particular item structure that includes requirements together with other item types will differ from a ReqIF export of the same item structure since the export will only include requirements whereas the document may include the other types of items. 
  • If there are issues with an import of a ReqIF generated from SystemWeaver into a different system, it may be that the target database is unable to import ReqIF. If this should be the case, there are third-party applications that many companies use to convert files so that they can be successfully imported.