Creating a Custom DOORS Importer in 5 Minutes
| 2012-01-13 | Posted by tcapelle under DOORS, Word |
DOORS provides a generic importer for MS Word. This importer is good for plain text documents, but doesn’t work well when the Word document is structured.
For example, my customer formats his requirements like this:
| [001] Instrument length must be less than 30 cm | ||||
| Attributes |
Revision |
Owner |
Severity |
|
|
1 |
E |
A |
||
| Category | Physical | |||
| Description | The length of the instrument must be less than 30 cm so that it can fit into the carrying case. | |||
| [002] Instrument width must be between 5 mm and 1.5 mm | ||||
| Attributes |
Revision |
Owner |
Severity |
|
|
2 |
E |
A |
||
| Category | Physical | |||
| Description | The total width of the instrument must be greater than 5 mm, but less than 1.5 mm for ease of use. | |||
| [003] Instrument build cost must be less than 0.05 USD | ||||
| Attributes |
Revision |
Owner |
Severity |
|
|
1 |
A |
B |
||
| Category | Cost | |||
| Description | The total cost of production for the instrument must be less than 5 cents. | |||
Using the DOORS Exporter in Word, DOORS produces this formal module:
The information is contained in this formal module, but hardly in the way that my customer would have liked!
The structure of the Word document is :
| [ID] Object Short Text value | ||||
| Attributes |
Attribute Name 1 |
Attribute Name 2 |
Attribute Name 3 |
|
|
Attribute Value 1 |
Attribute Value 2 |
Attribute Value 3 |
||
| Category | Object attribute “Category” value | |||
| Description | Object Text value | |||
Therefore each Word table corresponds to 1 DOORS Object, with the other table values used to fill-in attribute values on that Object.
For example, this Word table:
| [001] Instrument length must be less than 30 cm | ||||
| Attributes |
Revision |
Owner |
Severity |
|
|
1 |
E |
A |
||
| Category | Physical | |||
| Description | The length of the instrument must be less than 30 cm so that it can fit into the carrying case. | |||
should produce this in DOORS:
So how do we solve this problem?
We’ll use the MDWorkbench and its DOORS and Word connectors to map the values into the desired Object structure.
First we need understand how the data is structured in Word so we can know how to get the values out of the document.
MDWorkbench has a Model Viewer that shows us Word document structure.
We can see that the Word document has some tables in it, which contain rows, which themselves contain cells.
We can also look at the structure of the DOORS formal module that we’d like to create.
By looking at the underlying DOORS representation of the Object created for the requirement in Word, we can see that we need to set the objectShortText, objectText, and some instantiatedAttributes.
Now we can write the rules that take the information from Word and create this structure in DOORS.
Creating the Import Rules
The first thing to do is to create a new ruleset in MDWorkbench, and to set the input and output models that we are going to use.
Then I usually start by pulling the information from my source, in this case Word.
Once I have figured out how to get the values out of Word, I set the values in DOORS. At this point, I start to break the logic into subrules for functions like creating a formal module and creating attributes on the objects.

And then I define the missing subrules:

(Here is the ruleset code: WordTableImporter.mqr)
And then I execute:
The resulting DOORS module is what I want:
Now I deploy, and add as an Add-In in Word.
Here is the full project zip file: DOORSWordTableImporter.zip











