I am currently working with DOORS and require assistance in comparing attributes of objects between two modules using DXL.
The objective is to compare attributes of objects across two modules. Each object possesses a unique identifier attribute, referred to as "ID". In the first module, this attribute is named "IE ID", while in the second module, it is labeled as "Req Id". Those attributes aids in identifying corresponding objects across modules. Once matching objects are identified based on this identifier, the goal is to compare other attributes of these objects to detect any disparities.
Although I have already developed some DXL code for this purpose, I am encountering challenges in efficiently comparing attributes and detecting differences between corresponding objects.
I require assistance in refining my DXL code to accurately compare attributes of objects across modules and efficiently identify any discrepancies.
Thank you for your assistance!
I tried this code :
Module m1 = current
Module m2 = edit("/Firts project/System/Module Verification")
Object obj1
Object obj2
string ID1
string ID2
ID1 = obj1."IE ID" ""
obj2 = obj1 in m2
if (obj2 != null) {
ID2 = obj2."Req Id" ""
if (ID1 == ID2) {
for attr in obj1 do {
if (attr != "IE ID") {
string att1 = attr ""
string att2 = obj2.(attr) ""
if (att1 != att2) {
print "Différence détectée pour l'objet " obj1."Absolute Number" " :"
print " Attribut : " attr
print " Module 1 : " att1
print " Module 2 : " att2
}
}
}
}
} else {
print "Objet non trouvé dans le deuxième module pour l'objet " obj1."Absolute Number"
}
But it shows me a lot of error messages
Edit: Update in the code snippets after the discussion in the other answers
If the general loop shall be:
Then the code for step 1 is
//here step 1
for obj1 in entire m1 do{
ID1 = obj1."IE ID" ""
//here step 2
}
Step 1 must be replaced if this is about DXL Layout columns or DXL Attributes. In these cases, the code for step 1 will just be
Module m1 = module obj
ID1 = obj."IE ID" ""
The code for step 2 will be
bool foundIt = false
for obj2 in entire m2 do {
ID2 = obj2."Req Id" ""
if (ID1 == ID2 ) {
foundIt = true
//here step 3
}
}
if (!foundIt) {
print "Objet non trouvé dans le deuxième module pour l'objet " obj1."Absolute Number" ""
}
The code for step 3 will be (if you iterate over the attributes defined in m1)
AttrDef ad1
for ad1 in m1 do {
// if the AttrDef exists for objects
if (ad1.object) {
string attrName = ad1.name
AttrDef ad2 = find (m1, attrName)
// if an attribute of the same name exists in m2
if (!null ad2) {
string att1 = obj1.attrName ""
string att2 = obj2.attrName ""
if (att1 != att2) {
// in DXL layout column, replace "print" with "display"
// in attribute DXL, replace print by one line containing "obj.attrDXLName=strMessage" with strMessage being a string variable filled with the message
print "Différence détectée pour l'objet " obj1."Absolute Number" " :"
print " Attribut : " attrName
print " Module 1 : " att1
print " Module 2 : " att2 "\n"
...
You might have to adopt this if some AttrDefs are defined as integer or Date, but the general steps should be rather clear now.