【问题标题】:Mapping dot notation in XMI在 XMI 中映射点表示法
【发布时间】:2018-09-24 02:23:12
【问题描述】:

自 2.1(或更高版本)以来,UML 引入了所谓的点表示法,它告诉角色名称除了关联端的点之外是否表示相对类中的拥有属性。从 2.5 开始,OMG 相当广泛地使用了这种表示法。

现在我想知道如何将其映射到 XMI。 UML 规范在 p 上声明。第717章

UMLEdge(Association/Connector/InstanceSpecification/Property/ConnectorEnd , isAssociationDotShown 已启用)

所以我希望在 XMI 中有一个属性,比如

<ownedEnd isAssociationDotShown="true" xmi:type="uml:Property" ...

我在 Enterprise Architect 中尝试过,但(难怪)它不起作用。 EA 正在使用它自己的扩展

<style value="Union=0;Derived=0;AllowDuplicates=0;Navigable=Unspecified;Owned=1;"/>

(最后是Owned=1)。当然我可以模仿那个符号,但是

  1. 这仅适用于 EA 和
  2. 我想坚持自己的标准
  3. 喜欢消化,因为我只是在这里猜测。

【问题讨论】:

  • 似乎合乎逻辑,但我不确定为什么如果它被拥有,为什么不显示点?
  • 我的问题是:我如何在 XMI 中编写代码,因为似乎没有(标准)构造来显示点一旦导入(比如说)EA。
  • XMI 似乎不支持关联端所有权点。也许假设是在将类模型序列化为 XMI 之前,它们必须被相关类中的相应引用属性替换。我猜 UML 图交换规范应该包括对它们的支持。
  • @GerdWagner 我也怀疑这一点。点符号“相对较新”的事实可能是造成这种情况的原因。太糟糕了。

标签: uml xmi


【解决方案1】:

属性 isAssociationDotShown 是 Annex B UML Diagram Interchange 中 UmlDiagramWithAssociations (UML 2.5 § B.7.15) 的一个属性,描述为

isAssociationDotShown : 布尔值 [1..1] = false
指示是否应使用点表示法进行关联。

请注意,默认情况下此属性为 false,这意味着图表不应显示关联点。

点符号本身在 UML (UML 2.5 § 11.5.4) 中定义为

关联分类器对关联的所有权可以用一个小的实心圆圈以图形方式表示,为简洁起见,我们将其称为一个

到 XMI 的映射实际上只不过是关联成员端的所有权。

来自 UML 规范的示例:

示例 1:两边都有点

InteractionFragmentInteraction之间的关联两边都有一个点,表示两端都属于相反的分类器。
事实上,在 OMG 提供的 xmi 中,我们发现:

<packagedElement xmi:type="uml:Association" xmi:id="A_fragment_enclosingInteraction" name="A_fragment_enclosingInteraction" memberEnd="Interaction-fragment InteractionFragment-enclosingInteraction"/>

没有拥有的目的。两端都由两端的分类器作为 OwnedAttributes 拥有

<ownedAttribute xmi:type="uml:Property" xmi:id="Interaction-fragment" name="fragment" type="InteractionFragment" isOrdered="true" aggregation="composite" subsettedProperty="Namespace-ownedMember" association="A_fragment_enclosingInteraction">
    <ownedComment xmi:type="uml:Comment" xmi:id="Interaction-fragment-_ownedComment.0" annotatedElement="Interaction-fragment">
        <body>The ordered set of fragments in the Interaction.</body>
    </ownedComment>
    <upperValue xmi:type="uml:LiteralUnlimitedNatural" xmi:id="Interaction-fragment-_upperValue" value="*"/>
    <lowerValue xmi:type="uml:LiteralInteger" xmi:id="Interaction-fragment-_lowerValue"/>
</ownedAttribute>

还有一个:

<ownedAttribute xmi:type="uml:Property" xmi:id="InteractionFragment-enclosingInteraction" name="enclosingInteraction" type="Interaction" subsettedProperty="NamedElement-namespace" association="A_fragment_enclosingInteraction">
    <ownedComment xmi:type="uml:Comment" xmi:id="InteractionFragment-enclosingInteraction-_ownedComment.0" annotatedElement="InteractionFragment-enclosingInteraction">
        <body>The Interaction enclosing this InteractionFragment.</body>
    </ownedComment>
    <lowerValue xmi:type="uml:LiteralInteger" xmi:id="InteractionFragment-enclosingInteraction-_lowerValue"/>
</ownedAttribute>

示例 2:一侧的点

StateInvariantConstraint 之间的关联仅在 Constraint 末尾有一个点
关联本身在 XMI 中定义为:

<packagedElement xmi:type="uml:Association" xmi:id="A_invariant_stateInvariant" name="A_invariant_stateInvariant" memberEnd="StateInvariant-invariant A_invariant_stateInvariant-stateInvariant">
    <ownedEnd xmi:type="uml:Property" xmi:id="A_invariant_stateInvariant-stateInvariant" name="stateInvariant" type="StateInvariant" subsettedProperty="Element-owner" association="A_invariant_stateInvariant">
        <lowerValue xmi:type="uml:LiteralInteger" xmi:id="A_invariant_stateInvariant-stateInvariant-_lowerValue"/>
    </ownedEnd>
</packagedElement>

没有点的那一端归协会所有。
带点的结尾是 StateInvariant 作为ownedAttribute 拥有的。

<ownedAttribute xmi:type="uml:Property" xmi:id="StateInvariant-invariant" name="invariant" type="Constraint" aggregation="composite" subsettedProperty="Element-ownedElement" association="A_invariant_stateInvariant">
    <ownedComment xmi:type="uml:Comment" xmi:id="StateInvariant-invariant-_ownedComment.0" annotatedElement="StateInvariant-invariant">
        <body>A Constraint that should hold at runtime for this StateInvariant.</body>
    </ownedComment>
</ownedAttribute>

导入 EA

不幸的是,EA 中的 xmi 导入函数似乎存在错误,因为它失去了拥有端的概念(以及点)。将其导入 EA (v14.5 BETA) 时,结果是:

【讨论】:

  • 谢谢,吉尔特。我将在今晚晚些时候对此进行调查。乍一看,我很惊讶他们(OMG;首字母缩写词太好了)将所有权作为图表的一部分而不是关联本身。所以仍然被困在“拥有的关联端”与“带有类型的属性”中。
  • 所以(在我现在必须离开之前)归结为使用ownedAttribute 来表示虚线变体 - 并希望 Sparx 在未来的某个时候解决这个问题?所以isAssociationDotShown 只是用于显示它的一些附加图表标志(想知道为什么它默认为false)。
  • @ThomasKilian 是的,至少我是这么理解的。
  • 查看 OMG 的 XMI 源代码是个好主意。应该想到这一点...我在导入后没有在 EA 中看到点,只是认为它们没有编码。但是很明显是EA在导入的时候出错了。叹息。
  • 啊,有趣,干得好。我想这是由于技术随着时间的推移而扩大以及希望与历史方法保持兼容。我同意 2.5 图表应默认为 true。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-22
  • 2012-04-04
相关资源
最近更新 更多