Main Content

remove

Class: slreq.Reference
Namespace: slreq

Remove referenced requirements

Syntax

count = remove(topRef)
count = remove(ref)

Description

count = remove(topRef) removes all descendant referenced requirements under the import node topRef as well as the import node itself. The function returns the number of referenced requirements removed.

count = remove(ref) removes the referenced requirement ref and the descendant referenced requirements. The function returns the number of referenced requirements removed. You can use this syntax only in the PostImportFcn callback.

Input Arguments

expand all

Import node, specified as an slreq.Reference object.

Referenced requirement, specified as a slreq.Reference object.

Output Arguments

expand all

The number of referenced requirements removed, returned as a double.

Examples

expand all

Load a requirement set file called myReqSet.

rs = slreq.load("myReqSet");

Get a handle to the import node.

topRef = children(rs);

Remove the import node and its descendant requirements.

count = remove(topRef)
count =

    46

This example shows how to remove an imported referenced requirement in the PostImportFcn callback.

Use slreq.import to import the ReqIF™ file mySpec.reqif into Requirements Toolbox™. Name the imported requirement set myReqSet, register the script myPreImportScript2 as the PreImportFcn, and register the script removePostImport as the PostImportFcn callback to use during import. Return a handle to the requirement set.

[~,~,rs] = slreq.import("mySpec.reqif",ReqSet="myReqSet", ...
    preImportFcn="myPreImportScript2",postImportFcn="removePostImport");

The script myPreImportScript2 uses slreq.getCurrentImportOptions to get the import options, then specifies the attribute mapping file to use during import.

type myPreImportScript2.m
importOptions = slreq.getCurrentImportOptions;
importOptions.MappingFile = "myMappingFile2.xml";

The mapping file myMappingFile2.xml maps these attributes from the ReqIF file to these properties in Requirements Toolbox:

  • ReqSum to Summary

  • Desc to Description

  • ID to Custom ID

The script myPostImportScript uses slreq.getCurrentObject to get a handle to the import node, gets the requirement set that the import node belongs to, then finds and removes the referenced requirement that has Summary set to Requirement 3.

type removePostImport.m
topRef = slreq.getCurrentObject;
rs = reqSet(topRef);
ref = find(rs,Type="Reference",Summary="Requirement 3");
count = remove(ref);

Version History

Introduced in R2019a