[ATL] Containment references cannot span across models [message #1009619] |
Fri, 15 February 2013 06:48  |
Eclipse User |
|
|
|
Hi members,
I have to fight with output elements written to the wrong file in a transformation with several (hierarchic) output metamodels, i.e. there are output metamodels otx.ecore and quantity.ecore, which is a sub-model of otx.ecore.
All output should be written to output.otx, the output file of the main model (otx.ecore); but sometimes, output from the sub-model (quantity.ecore) is written to its output file output.quantity instead.
As I have recently figured out, the problem seems to be caused by the ATL 'collect', which creates its own intermediate collection:
lazy rule SubtractAtom2Term {
from
source: transformate!SubtractAtom
to
otxTerm: otx!Subtract(
-- This works as desired, i.e. the quantity goes to output.otx:
numeral <- source.numeral->createQuantity(),
-- This does not work, i.e. the quantities go to output.quantity:
subtrahend <- source.subtrahends->collect(s | s->createQuantity())
-- Error message: Containment references cannot span across models.
)
}
As posted here before, cross-model references are activated.
Any suggetions? Maybe how to work around using the 'collect'?
Thank you for any input.
|
|
|
|
|
|
|
Re: [ATL] Containment references cannot span across models [message #1010814 is a reply to message #1009619] |
Mon, 18 February 2013 04:34   |
Eclipse User |
|
|
|
Hugo and Dennis, thank you for your help. Seems we're going into detail on this...
@Dennis:
- You can find the 'create' helper on top of my second post - it is the helper which calls the lazy rule. Please note that there are many such helpers (in different contexts, but of the same name) in my transformation, which call different lazy rules.
- I do not know how to use the main model identifier (otx) in order to create sub-model (quantity) elements; Hugo and I have discussed that approach in another thread before, with no success on my side.
The name spaces in the XML schemata (otx.xsd imports quantity.xsd) and the Ecore model generated from them are org.iso.otx and org.iso.otx.quantity, but stuff like otx!"org::iso::otx::quantity::Quantity" leads to an error in ATL.
Maybe I should make even clearer why I think that the collection created by ATL is the problem: Both output bindings (numeral and subtrahend) in the given lazy rule call the helper createQuantity, which in both cases returns a sub-model (quantity) element.
If the helper is called directly (numeral), the sub-model element is inserted correctly into the main model output file - there is no containment reference, as it is directly contained. But if the helper is called by an iterator (collect), the sub-model output elements (Quantities) are written to the quantity output file, which would require a cross-file reference.
I'm wondering why that happens when using collect only.
[Updated on: Mon, 18 February 2013 05:37] by Moderator
|
|
|
Re: [ATL] Containment references cannot span across models [message #1035938 is a reply to message #1010814] |
Sun, 07 April 2013 14:00   |
Eclipse User |
|
|
|
Op 18-02-13 10:35, Gunnar Arndt schreef:
> Hugo and Dennis, thank you for your help. Seems we're going into detail on
> this...
>
> @Dennis:
>
> You can find the 'create' helper on top of my second post - it is the helper
> which calls the lazy rule. Please note that there are many such helpers (in
> different contexts, but of the same name) in my transformation, which call
> different lazy rules.
> I do not know how to use the main model identifier (otx) in order to create
> sub-model (quantity) elements; Hugo and I have discussed that approach in
> another thread before, with no success on my side.
> The name spaces in the XML schemata (otx.xsd imports quantity.xsd) and the
> Ecore model generated from them are org.iso.otx and org.iso.otx.quantity, but
> stuff like "org::iso::otx::Quantity" leads to an error in ATL.
Hmm, ATL normally detects the imports closure of Ecore metamodels by following
the outward references/inheritance relationships of each EClass it traverses.
Unless no otx metaclass has an explicit reference to a quantity metaclass,
this approach should be able to find quantity EClasses as part of the otx
metamodel, e.g. OTX!Quantity or OTX!"org::iso::otx::Quantity".
>
> Maybe I should make even clearer why I think that the collection created by
> ATL is the problem: Both output bindings (numeral and subtrahend) in the given
> lazy rule call the helper createQuantity, which in both cases returns a
> sub-model (quantity) element.
> If the helper is called directly (numeral), the sub-model element is inserted
> correctly into the main model output file - there is no containment reference,
> as it is directly contained. But if the helper is called by an iterator
> (collect), the sub-model output elements (Quantities) are written to the
> quantity output file, which would require a cross-file reference.
>
> I'm wondering why that happens when using collect only.
In the first case you're assigning to "numeral" and in the second case you're
assigning to "subtrahend". Those are different properties. Please verify
against both.
Dennis
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06324 seconds