如何制作一个dxl属性,如果单词“要”一词。在另一个属性中存在于IBM理性门中?

发布于 2025-02-05 18:09:01 字数 407 浏览 1 评论 0 原文

如果在另一个属性(称为“ text”)中存在单词“将“”“将“”单词“”存在,则试图制作DXL boolean属性(称为“是要求?”),否则为false。

在门模块上的编辑模式中,我单击“编辑” - >属性 - > “需要吗?” - >编辑... - >检查DXL属性 - >浏览... - >新,编写代码 - >好的,关闭所有窗口,工具 - >刷新DXL属性

Object o
for o in current Module do{

 if((o."Text") contains "shall")
  {
   o."Is Requirement?" = "True"
  }
 else
  {
   o."Is Requirement?" = "False"
  }

}

Trying to make a DXL boolean attribute (called "Is Requirement?") true if the word "shall" exists in another attribute (called "Text"), and otherwise false.

In edit-mode on the DOORS module, I click Edit -> Attributes -> "Is Requirement?" -> Edit... -> check DXL attribute -> Browse... -> New, write the code -> Ok, close all windows, Tools -> Refresh DXL Attributes

Object o
for o in current Module do{

 if((o."Text") contains "shall")
  {
   o."Is Requirement?" = "True"
  }
 else
  {
   o."Is Requirement?" = "False"
  }

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪都笑了 2025-02-12 18:09:01

这里的几个方面:

  • DXL属性的代码是一个特定对象的代码和一个特定属性,该对象可在变量 obj 中可用,该属性可在 attrdxlname 。 DXL属性中的对象也没有循环,也没有DXL布局列中的循环。
  • 包含具有签名 int contains(buffer b,string word,int offset),它在缓冲区而不是在字符串上运行。您可能要使用 bool findplaintext(字符串s,string sub,int& offset,int& length,bool matchcase [,bool reverse])
  • o。“ text” 将返回对象引用。但是您想检查属性的内容。要获取字符串属性的内容,您必须将对象引用引入字符串,例如,将引用与字符串相连。您可以使用 obj。“ text”“”
  • 您的模块中是否真的有一个属​​性“文本”?通常,人们使用属性“对象文本”。

这更改了您的代码,以

int offset, length
bool matchCase = true
obj.attrDXLName = findPlainText (obj."Object Text" "", "shall", offset, length, matchCase)

记住您的DXL属性的类型必须是布尔值才能使您工作的。

最后但并非最不重要的一点:您确定您的状况“包含文本应”就足够了吗?那所有包含“应”的单词()? Internet中某个地方有一些有关此主题的线程。搜索“需求DXL应浅”。而且:“会足够”吗?那“可能”,“应该”,“必须”呢?

Several aspects here:

  • The code for a DXL attribute is the code for one specific object and one specific attribute, the object is available in the variable obj, the attribute is available in attrDXLName. There is no loop over objects neither in DXL attributes nor in DXL layout columns.
  • contains has the signature int contains(Buffer b, string word, int offset), it operates on a Buffer, not on a string. You probably want to use bool findPlainText(string s, string sub, int &offset, int &length, bool matchCase[, bool reverse])
  • o."Text" will return an object reference. But you want to check the content of the attribute. To get the content of a string attribute, you have to cast the object reference to string, e.g. by concatenating the reference with a string. You can use obj."Text" "".
  • Is there really an attribute "Text" in your module? Usually, people use the attribute "Object Text".

This changes your code to

int offset, length
bool matchCase = true
obj.attrDXLName = findPlainText (obj."Object Text" "", "shall", offset, length, matchCase)

Remember that the type of your DXL attribute must be boolean for this to work.

And last but not least: Are you sure that your condition "Text contains shall" is sufficient? What about all the words that contain "shall" (https://www.thefreedictionary.com/words-containing-shall)? There are some threads about this topic somewhere in the internet. Search for "Requirement DXL shall shallow". And: is "shall" enough? What about "may", "should", "must"?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文