Main Content

setAttribute

Class: slreq.Requirement
Namespace: slreq

Set requirement property values

Syntax

setAttribute(req,propertyName,propertyValue)

Description

setAttribute(req,propertyName,propertyValue) sets a requirement property, propertyName, to the value specified by propertyValue for the requirement req. The property can be a built-in property, a custom attribute, or a stereotype property.

Note

To set the value of a stereotype property, you must pass the fully qualified name of the property. For example, the fully qualified name for a property called Status in a stereotype called myStereotype in a profile called myProfile is myProfile.myStereotype.Status.

Input Arguments

expand all

Requirement, specified as an slreq.Requirement object.

Requirement property name, specified as a string scalar or character vector.

Example: "Description"

Requirement property value, specified as a:

  • String scalar

  • Character array

  • boolean

  • datetime

  • single

  • double

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • enumeration

The data type depends on the type of the built-in property, custom attribute, or stereotype property.

Examples

expand all

This example shows how to assign a profile to a requirement set and get and set stereotype property values for requirements.

Open the ShortestPath project.

openProject("ShortestPath");

Load the shortest_path_tests_reqs requirement set.

rs = slreq.load("shortest_path_tests_reqs");

Assign the TestReqProfile profile to the shortest_path_tests_reqs requirement set.

importProfile(rs,"../TestReqProfile.xml");

Find the requirement with index 2.1.1. Apply the TestRequirement stereotype to the requirement.

testReq = find(rs,Index="2.1.1");
testReq.Type = "TestReqProfile.TestRequirement";

Get the value of the Reviewed stereotype property.

val = getAttribute(testReq,"TestReqProfile.TestRequirement.Reviewed")
val = 
0

Set the value of the Reviewed stereotype property to 1.

setAttribute(testReq,"TestReqProfile.TestRequirement.Reviewed",1)

Tips

  • To set property values for links, use the setAttribute method of slreq.Link.

Version History

Introduced in R2018a