Implied linking in Refining mode [message #986193] |
Mon, 19 November 2012 12:00 |
|
I have a refining transformation that adds elements based on a DTD model to a base UML model. I would like to use the declarative base pattern shown below, that has been taken from the standard manual. My code is in the second snippet.
rule Case2_R1 {
from
i : MM_A!ClassA
to
o_1 : MM_B!Class1 (
linkToClass2 <- i.linkToClassB
)
}
rule Case2_R2 {
from
i : MM_A!ClassB
to
o_1 : MM_B!Class2 (
...
),
...
}
The code below is only allowed to run if 'inter-model relations are enabled'. If that is enabled, it fails with a typecast:
org.eclipse.wst.dtd.core.internal.emf.impl.DTDFileImpl cannot be cast to net.jgsuess.uml14.foundation.core.Namespace
The intention of the code is that a UML class generated from a DTD element should link to the UML package that corresponds to the DTD elements' DTD file.
I assume I am doing something wrong in setting up the matching.
-- @atlcompiler atl2010
-- @nsURI UML=http://jgsuess.net/uml14
-- @nsURI DTD=DTD.xmi
module transform;
create OUT: UML refining IN: UML, dtd: DTD;
rule File2Package {
from
s: DTD!DTDFile
to
t: DTD!DTDFile,
p: UML!Package (
name <- 'dtdfile'
)
}
rule Element2Class {
from
s: DTD!DTDElement
to
t: DTD!DTDElement,
c: UML!Class (
namespace <- s.DTDFile,
name <- s.name
)
}
[Updated on: Mon, 19 November 2012 12:04] Report message to a moderator
|
|
|
Re: Implied linking in Refining mode [message #986194 is a reply to message #986193] |
Mon, 19 November 2012 12:17 |
|
Disregard my message above. For those looking, underneath is the solution:
- Inter-model relations have to be on
- You have to use thisModule.resolveTemp to obtain the secondary element
The thisModule.resolveTemp is necessary, because in this case the interesting elements are created as side-effects.
-- @atlcompiler atl2010
-- @nsURI UML=http://jgsuess.net/uml14
-- @nsURI DTD=DTD.xmi
module transform;
create OUT: UML refining IN: UML, dtd: DTD;
rule File2Package {
from
s: DTD!DTDFile
to
t: DTD!DTDFile,
p: UML!Package (
name <- 'dtdfile'
)
}
rule Element2Class {
from
s: DTD!DTDElement
to
t: DTD!DTDElement,
c: UML!Class (
namespace <- thisModule.resolveTemp(s.DTDFile, 'p'),
name <- s.name
)
}
|
|
|
Powered by
FUDForum. Page generated in 0.03049 seconds