Main Content

updateSrcFileLocation

Class: slreq.ReqSet
Package: slreq

Update document location of imported requirements

Syntax

updateSrcFileLocation(rs,oldID,newID)

Description

updateSrcFileLocation(rs,oldID,newID) updates the Artifact property from oldID to newID for the referenced requirements in the requirement set rs that have Artifact set to oldID. Use this function to update the external requirements document associated with imported requirements.

Input Arguments

expand all

Requirement set, specified as an slreq.ReqSet object.

Resource identifier for the original external document, specified as a string scalar or character vector.

Resource identifier for the new external document, specified as a string scalar or character vector.

Examples

expand all

This example shows how to update the source file location for referenced requirements in an imported requirement set.

Open the Requirements Definition for a Cruise Control Model project and load the crs_req requirement set.

slreqCCProjectStart;
rs = slreq.load("crs_req");

Copy the crs_req.docx document and name it crs_req_v2.docx. Save the new file in the same folder.

oldPath = fullfile(pwd,"documents","crs_req.docx");
newPath = fullfile(pwd,"documents","crs_req_v2.docx");
copyfile(oldPath,newPath);

Update the referenced requirements in the requirement set crs_req that point to crs_req.docx as the source file to point to crs_req_v2.docx.

updateSrcFileLocation(rs,"crs_req.docx","crs_req_v2.docx")

To confirm that the source file updated, get a handle to the Import node for the requirement set and check the Artifact property.

topRef = children(rs);
srcFile = topRef.Artifact
srcFile = 
'crs_req_v2.docx'

Cleanup

Clear the requirement set and close the project.

slreq.clear;
close(currentProject);

Tips

  • If you rename or move an external requirements document, you can update the link destinations for direct links by using updateDocUri.

  • To update the external requirements document resource identifier for referenced requirements imported from non-file-based domains, use updateSrcArtifactUri.

Version History

Introduced in R2017b