Define Custom Document Interface for Importing Requirements
You can define custom document interfaces to import requirements from third-party applications that Requirements Toolbox™ does not provide built-in support for. To define a custom document interface, create a function that specifies the interface properties and callback functions to use during the import process. You can also create a custom version of a built-in Requirements Toolbox document interface for a supported products, such as Microsoft® Word. Your custom version of a built-in document interface can have different properties or callback functions than the built-in type.
Alternatively, you can import requirements from third-party applications that Requirements Toolbox does not support by importing ReqIF™ files. For more information, see Import Requirements from ReqIF Files.
Note
You can also define a custom document interface to link directly to requirements from third-party applications that Requirements Toolbox does not support. For more information, see Define Custom Document Interface for Direct Linking to Requirements.
Define Custom Document Interface
To define a custom document interface for importing requirements:
Author a function that defines and returns an instance of the document interface object,
ReqMgr.LinkableType. Your function must take this form:Thefunction docDomain = myDomainType docDomain = ReqMgr.LinkableType; end
docDomainvariable represents the document interface object.Define these properties for the document interface object:
Name Description Value Types Example Value RegistrationRequirement document interface name, specified as a string scalar or character vector. The value of this property must be the same as the document interface definition function name. String
Character vector
custom_wordLabelLabel for the custom document type in the Importing Requirements Dialog, specified as a string scalar or character vector. String
Character vector
"My Custom Document Interface"IsFileIndicator for the file-based requirement documents, specified as a
logical1(true) or0(false). Set the value to1if your requirement document is file-based, or0if your requirement document is not file based.Logical1(true) or0(false)1ExtensionsAllowed file type extensions for file based requirement documents, specified as a cell array of character vectors. Leave empty for requirement documents that are not file based. Cell array of character vectors {'.doc','.docx'}LocDelimetersCharacters that are used to specify the supported types of location identifiers in the requirement document, specified as a string scalar or character array that is a combination of one or more of these characters:
?: Used to search for text in the document@: Used as a named item such as a requirement ID#: Page number or item number>: Item number$: Cell address in spreadsheet
This property is optional.
Character array containing one or more of these characters: ?,@,#,>,$'?@#'Determine which callback functions your document interface object needs:
Callback Description Required or Optional? Function Syntax and Description NavigateFcnFunction to navigate from imported requirement to original requirement in external document using Show In Document in the Requirements Editor Optional, but if you do not define this function, Show In Document button does not work NavigateFcn(document,id)opens the external requirement document specified bydocumentto the requirement specified byid.ContentsFcnFunction to get the table of contents of the external requirement document or server Required [labels,depths,ids] = ContentsFcn(document)returns requirements information as cell arrays for the external document specified bydocument.labelscontains requirements text,idscontains requirements identifiers, anddepthscontains the level of the requirement in the hierarchy.BrowseFcnFunction to execute when you click the Browse button in the Importing Requirements dialog box for requirement documents that are not file-based. This function is not required for file-based requirements domains. Optional BrowseFcnopens the browser for requirement documents in the non-file-based requirements application.SummaryFcnFunction to get text for the Summaryproperty of the imported requirementsOptional, but if you do not define this function, you have to manually map an imported attribute to the Summaryproperty. For more information, see Create and Edit Attribute Mappings.summary = SummaryFcn(document,id)returns the summary for the requirement specified by the identifieridin the external requirement document specified bydocument.HtmlViewFcnFunction to get the HTML view of the requirements content for rich text import and assign it to the Descriptionproperty of the imported requirementsOptional, but if you do not define this function or TextViewFcn, you have to manually map an imported attribute to theDescriptionproperty. For more information, see Create and Edit Attribute Mappings.html = HtmlViewFcn(document,id)returns the HTML content of the requirement specified by the identifieridin the external requirement document specified bydocument.TextViewFcnFunction to get the plain text view of the requirements content for plain text import Optional, but if you do not define this function or HtmlViewFcn, you have to manually map an imported attribute to theDescriptionproperty. For more information, see Create and Edit Attribute Mappings.text = TextViewFcn(document,id)returns the plain text content of the requirement specified by the identifieridin the external requirement document specified bydocument.AttributeNamesFcnFunction to get the names of the requirement attributes to import Optional, but if you do not define this function, your imported requirements do not have custom attributes or properties except for those imported by SummaryFcn,HtmlViewFcn, orTextViewFcn. For more information about custom attributes, see Create and Edit Attribute Mappings.[attributes,datatype] = AttributeNamesFcn(document,id)returns the attribute names,attributes, and details about the attribute data type,datatype, for the requirement specified by the identifieridin the external requirement document specified bydocument.If the attribute type is a Boolean, the
datatypeoutput is the default Boolean value,trueorfalse.If the attribute type is numeric, the
datatypeoutput is the default numeric value.If the attribute is an enumeration, the
datatypeoutput is a cell array of character vectors of the possible enumeration values.
GetAttributeFcnFunction to get value of the requirement attributes to import Required if you define a callback function for AttributeNamesFcnvalue = GetAttributeFcn(document,id,attrName)returns the attribute value of the attributeattrNamefor the requirement specified by the identifieridin the external requirement document specified bydocument.CreateURLFcnFunction to get hyperlink to navigate to linked requirement in requirements reports Optional url = CreateURLFcn(document,documentURL,id)returns the URL for the requirement specified by the identifieridin the external requirement document specified bydocumentor the document URLdocumentURL.UrlLabelFcnFunction to get the hyperlink text for the requirement navigation URL in requirements reports Required if you define a callback for CreateURLFcnlabel = UrlLabelFcn(document,id)returns a label for the requirement specified by the identifieridin the external requirement document specified bydocument.BacklinkCheckFcnFunction to check if backlink exists in external requirement documents. For more information about backlinks, see Manage Navigation Backlinks in External Requirements Documents. Optional [linkExists,newLinkURL] = BacklinkCheckFcn(mwArtifactName,mwItemId,extDoc,extReq)checks whether the external requirementextReqin the external requirement documentextDochas a backlink to the linkable item in MATLAB® or Simulink® specified bymwItemIdin the artifactmwArtifactName.If the backlink exists,
linkExistsreturnstrueandnewLinkURLreturns empty.If the backlink does not exist,
linkExistsreturnsfalseandnewLinkURLcontains the URL to insert as a backlink.
BacklinkInsertFcnFunction to insert backlinks in external requirement documents. For more information about backlinks, see Manage Navigation Backlinks in External Requirements Documents. Required if you define a callback function for BacklinkCheckFcn[navCmd,dispText] = BacklinkInsertFcn(extDoc,extReq,mwSourceArtifact,mwItemId,mwDomain)inserts a backlink from the external requirement specified byextReqin the external requirement documentextDocto the linkable item in MATLAB or Simulink specified bymwItemIdin the artifact specified bymwSourceArtifactwith the artifact document interfacemwDomain. The function returns the navigation command that the backlink uses,navCmd, and the displayed hyperlink text for the backlink,dispText.BacklinksCleanupFcnFunction to check for stale backlinks in external requirement documents. For more information about backlinks, see Manage Navigation Backlinks in External Requirements Documents. Optional, but if this function is not defined, the Update Backlinks context menu option in the Requirements Editor cannot check for and delete stale backlinks [countRemoved, countChecked] = BacklinksCleanupFcn(extDoc,mwSourceArtifact,mwLinksDataMap)checks the backlinks in the external requirement documentextDocthat point to linkable items in the MATLAB or Simulink artifactmwSourceArtifactand deletes backlinks that do not have a corresponding forward link in the Requirements Toolbox link map specified bymwLinksDataMap.[countRemoved, countChecked] = BacklinksCleanupFcn(extDoc,mwSourceArtifact,mwLinksDataMap,saveBeforeCleanup)saves the requirement document before deleting the backlinks.
BacklinkDeleteFcnFunction to delete backlinks in external requirement document. For more information about backlinks, see Manage Navigation Backlinks in External Requirements Documents. Optional success = BacklinkDeleteFcn(extDoc,extReq,mwSourceArtifact,mwItemId)deletes the backlink from the external requirement specified byextReqin the external requirement documentextDocthat points to the linkable item in MATLAB or Simulink specified bymwItemIdin the artifact specified bymwSourceArtifact.Author the callback functions that your document interface needs as local functions in the main function.
Assign the callback function handles to the corresponding properties of the document interface object.
For an example of a custom document interface, see the
custom_jira
function.
open(fullfile(matlabroot,"toolbox","slrequirements", ... "slrequirements","linktype_examples","custom_jira.m"))
Define Custom Version of Built-In Document Interface
To define a custom version of a built-in document interface:
Author a function that defines and returns an instance of one of the built-in document interfaces:
Microsoft Word:
linktypes.linktype_rmi_wordMicrosoft Excel®:
linktypes.linktype_rmi_excelIBM® DOORS®:
linktypes.linktype_rmi_doors
Your function must take this form:
function docDomain = custom_word docDomain = linktypes.linktype_rmi_word; end
Overwrite the
RegistrationandLabelproperties of the document interface object by setting them to custom values. You can also overwrite other properties. For more information, see Define Custom Document Interface.Determine which callback functions to overwrite. For more information, see Define Custom Document Interface.
Author new callback functions as local functions in the main function.
Assign the callback function handles to the corresponding properties of the document interface object.
For example, this code sets the
NavigateFcnproperty of the document interface object to a local function calledmyNavigateFcn.function docDomain = custom_word docDomain = linktypes.linktype_rmi_word; docDomain.NavigateFcn = @myNavigateFcn; end function myNavigateFcn(document,id) end
For an example of a custom version of a built-in document interface, see
the custom_word
function.
open(fullfile(matlabroot,"toolbox","slrequirements", ... "slrequirements","linktype_examples","custom_word.m"))
Use Custom Document Interface During Import
To use the custom document interface during import:
Register the custom document interface.
rmi register myDomainType
Open the Requirements Editor. For more information, see Open the Requirements Editor App.
Click Import.
In the Importing Requirements dialog, set Document type to the custom document interface.

For more information about importing requirements, see Import Requirements from Third-Party Applications.
The custom domain interface registration persists between MATLAB sessions. To unregister the document interface, enter:
rmi unregister myDomainType