DXL:跨模块比较对象的属性

问题描述 投票:0回答:2

我目前正在使用 DOORS,需要帮助使用 DXL 比较两个模块之间的对象属性。

目标是比较两个模块中对象的属性。每个对象都拥有唯一的标识符属性,称为“ID”。在第一个模块中,该属性被命名为“IE ID”,而在第二个模块中,它被标记为“Req Id”。这些属性有助于跨模块识别相应的对象。一旦根据此标识符识别出匹配对象,目标就是比较这些对象的其他属性以检测任何差异。

虽然我已经为此目的开发了一些 DXL 代码,但在有效比较属性和检测相应对象之间的差异方面遇到了挑战。

我需要帮助完善我的 DXL 代码,以准确比较跨模块的对象属性并有效识别任何差异。

感谢您的协助!

我尝试过这段代码:

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"
}

但是它向我显示了很多错误消息

attributes ibm-doors
2个回答
0
投票

你的代码几乎是正确的,但有一些错误。

如果一般循环应为:

  1. 迭代 m1 中的所有对象,将 o1 设置为当前对象
  2. 现在迭代 m2 中的所有对象,直到找到具有正确 ID 的对象 o2
  3. 现在迭代每个属性定义(在 m1 或 m2 中定义)并比较值。

第 1 步的代码是

//here step 1
for obj1 in entire m1 do{
   ID1 = obj1."IE ID" ""
   //here step 2
}

第 2 步的代码为

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" ""
}

步骤 3 的代码将是(如果您迭代 m1 中定义的属性)

AttrDef ad1
for ad1 in m1 do {
   // if the AttrDef exists for objects
   if (ad1.object) {
     string attrName = ad1.name
     string att1 = obj1.attName ""
     string att2 = obj2.attName ""
     if (att1 != att2) {     
        print "Différence détectée pour l'objet " obj1."Absolute Number" " :" 
        print "  Attribut : " attrName
        print "  Module 1 : " att1
        print "  Module 2 : " att2  "\n"
...

如果某些 AttrDef 被定义为整数或日期,您可能必须采用此方法,但一般步骤现在应该相当清楚了。


0
投票

感谢您的回复。实际上,“for”循环不是必需的,因为无论如何都会为每个对象执行代码,因为代码将放置在对象属性中。

如果我正确理解了你的代码并且删除了主“for”循环,那么我将得到以下代码:

Module m1 = current
Module m2 = edit("/Firts project/System/Module Verification")

Object obj1
Object obj2
string ID1
string ID2

for obj1 in entire m1 do{
   ID1 = obj1."IE ID" ""
   bool foundIt = false
    for obj2 in entire m2 do {
        ID2 = obj2."Req Id" ""
        if (ID1 == ID2 ) {
        foundIt = true
        AttrDef ad1
            for ad1 in m1 do {
   // if the AttrDef exists for objects
                if (ad1.object) {
                     string attrName = ad1.name
                     string att1 = obj1.attName ""
                     string att2 = obj2.attName ""
                     if (att1 != att2) {     
                        print "Différence détectée pour l'objet " obj1."Absolute Number" " :" 
                        print "  Attribut : " attrName
                        print "  Module 1 : " att1
                        print "  Module 2 : " att2  "\n"
                    }
                }
            }
        }
    }
}
if (!foundIt) {
   print "Objet non trouvé dans le deuxième module pour l'objet " obj1."Absolute Number" ""
}

但我仍然遇到这些错误:

-E- DXL: Line:21 Incorrect arguments for (.)
-E- DXL: Line:21 Incorrectly concatenated tokens
-E- DXL: Line:21 Undeclared variable (attName)
-E- DXL: Line:22 Incorrect arguments for (.)
-E- DXL: Line:22 Incorrectly concatenated tokens
-E- DXL: Line:34 Incorrect argument for (!)
-E- DXL: Line:34 Undeclared variable (foundIt)
-E- DXL: Line:34 Incorrect arguments for (if)
-E- DXL: Line:21 Incorrectly concatenated tokens
-E- DXL: Line:22 Incorrectly concatenated tokens
© www.soinside.com 2019 - 2024. All rights reserved.