Repository navigation
ReqIF Concepts
A ReqIF document separates what kind of information a requirement carries (its type) from the information itself (its values). Once you see that split, the rest of the object model follows. Every class on this page is a C# class in the ReqIFSharp namespace with the same name as the element in the ReqIF specification.
classDiagram
direction LR
ReqIF *-- ReqIFHeader : TheHeader
ReqIF *-- ReqIFContent : CoreContent
ReqIFContent *-- DatatypeDefinition : DataTypes
ReqIFContent *-- SpecType : SpecTypes
ReqIFContent *-- SpecObject : SpecObjects
ReqIFContent *-- Specification : Specifications
ReqIFContent *-- SpecRelation : SpecRelations
ReqIFContent *-- RelationGroup : SpecRelationGroups
SpecType *-- AttributeDefinition : SpecAttributes
AttributeDefinition --> DatatypeDefinition : Type
SpecObject *-- AttributeValue : Values
AttributeValue --> AttributeDefinition : AttributeDefinition
SpecObject --> SpecObjectType : Type
Specification *-- SpecHierarchy : Children
SpecHierarchy *-- SpecHierarchy : Children
SpecHierarchy --> SpecObject : Object
SpecRelation --> SpecObject : Source
SpecRelation --> SpecObject : Target
ReqIFHeader describes the exchange: Title, Comment, CreationTime, SourceToolId (the tool the data came from), ReqIFToolId (the tool that wrote the file), ReqIFVersion and RepositoryId.
Datatype definitions (ReqIFContent.DataTypes) are the primitive types of the document:
| Class | Holds |
|---|---|
DatatypeDefinitionString |
text, up to MaxLength characters |
DatatypeDefinitionXHTML |
rich text: formatted XHTML with tables, lists and embedded images |
DatatypeDefinitionInteger |
whole numbers between Min and Max
|
DatatypeDefinitionReal |
decimal numbers between Min and Max, with an Accuracy
|
DatatypeDefinitionBoolean |
true or false |
DatatypeDefinitionDate |
a date and time |
DatatypeDefinitionEnumeration |
a fixed list of EnumValues (SpecifiedValues), for example Draft, Approved, Rejected
|
Spec types (ReqIFContent.SpecTypes) are the "templates" of the document. Each spec type lists its attribute definitions (SpecAttributes): the named fields that elements of that type have, each of one datatype. A Requirement type might have the attributes ID (String), Text (XHTML) and Status (Enumeration).
There is one spec type class for each kind of element it describes:
| Spec type | Describes |
|---|---|
SpecObjectType |
requirements, headings and other SpecObjects |
SpecificationType |
Specifications (documents) |
SpecRelationType |
SpecRelations (trace links), for example satisfies or refines
|
RelationGroupType |
RelationGroups |
Attribute definitions come in the same flavours as datatypes: AttributeDefinitionString, AttributeDefinitionXHTML, AttributeDefinitionEnumeration and so on. Each can have a DefaultValue.
Spec objects (ReqIFContent.SpecObjects) are the requirements themselves, and also headings, notes, or whatever else the source tool exports. A spec object has a Type (a SpecObjectType) and a list of Values, one attribute value per filled-in attribute. Each value points to its attribute definition:
| Attribute value | The value property |
|---|---|
AttributeValueString |
TheValue (string) |
AttributeValueXHTML |
TheValue (XHTML string), plus ExtractUnformattedTextFromValue() for plain text |
AttributeValueInteger |
TheValue (long) |
AttributeValueReal |
TheValue (double) |
AttributeValueBoolean |
TheValue (bool) |
AttributeValueDate |
TheValue (DateTime) |
AttributeValueEnumeration |
Values (the selected EnumValues) |
Every attribute value also has ObjectValue, which returns the value as an object whatever the type.
Specifications (ReqIFContent.Specifications) are the documents a user sees in a requirements tool. A specification does not contain spec objects directly. It contains a tree of SpecHierarchy nodes (Children), and each node points to one spec object (Object). The same spec object can appear in several specifications, or several times in one.
Spec relations (ReqIFContent.SpecRelations) are trace links: a Source spec object, a Target spec object and a Type. Relations can carry attribute values too, for example a suspect flag.
Relation groups (ReqIFContent.SpecRelationGroups) bundle relations between two specifications, for example all links from the stakeholder requirements to the system requirements.
Everything with an identity derives from Identifiable:
-
Identifier: a unique id, often a GUID. References in the XML use it. -
LongName: the human-readable name. -
Description,LastChangeandAlternativeId.
Element types derive from AccessControlledElement, which adds IsEditable.
XHTML values can embed images and other files through <object> elements. ReqIFSharp exposes them as ExternalObjects on AttributeValueXHTML.ExternalObjects. In a .reqifz archive, the files themselves sit next to the ReqIF document. See Reading ReqIF.
The model classes carry [ReqIfClass] and [ReqIfProperty] attributes with the UML metadata from the specification: the ReqIF element name, whether a class is abstract, and each property's multiplicity and aggregation. Use them to generate documentation, user interfaces or mappings by reflection:
using System.Reflection;
using ReqIFSharp;
var classInfo = typeof(SpecObject).GetCustomAttribute<ReqIfClassAttribute>();
Console.WriteLine($"{classInfo.Name} (abstract: {classInfo.IsAbstract})");
foreach (var property in typeof(SpecObject).GetProperties())
{
var info = property.GetCustomAttribute<ReqIfPropertyAttribute>();
if (info != null)
{
var upper = info.UpperValue == int.MaxValue ? "*" : info.UpperValue.ToString();
Console.WriteLine($" {property.Name} [{info.LowerValue}..{upper}] {info.Aggregation}");
}
}SPEC-OBJECT (abstract: False)
Type [1..1] None
Values [0..*] Composite
Description [0..1] None
Identifier [1..1] None
...
copyright @ Starion Group S.A.