Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Transformation of References with same name
[ATL] Transformation of References with same name [message #627019] Wed, 22 September 2010 16:00 Go to next message
Eclipse UserFriend
I use ATL to transform an ecore model. My problem is that there are severeal references with the same name but in different classes. in my target metamodel(OWL) references are modeled as independend concepts, so I have a problem with my transformation. I haven't found a way to name each resulting reference uniquely. At the moment my references are all mixed together. Is there a solution to this in ATL or do you think it's easier to change the ecore model?
Re: [ATL] Transformation of References with same name [message #627936 is a reply to message #627019] Thu, 23 September 2010 02:38 Go to previous messageGo to next message
Eclipse UserFriend
Le 22/09/2010 22:00, moggi a écrit :
> I use ATL to transform an ecore model. My problem is that there are
> severeal references with the same name but in different classes. in my
> target metamodel(OWL) references are modeled as independend concepts, so
> I have a problem with my transformation. I haven't found a way to name
> each resulting reference uniquely. At the moment my references are all
> mixed together. Is there a solution to this in ATL or do you think it's
> easier to change the ecore model?

Can you give few examples so we may visualize the problem?
--
Cordialement

Vincent MAHÉ

Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
Re: [ATL] Transformation of References with same name [message #628181 is a reply to message #627019] Thu, 23 September 2010 06:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

A simple ecore file that describes the proble ist
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="Package"
    nsURI="www.example.com" nsPrefix="pa">
  <eClassifiers xsi:type="ecore:EClass" name="Class1">
    <eStructuralFeatures xsi:type="ecore:EReference" name="class1" eType="#//Class1"/>
  </eClassifiers>
  <eClassifiers xsi:type="ecore:EClass" name="Class2">
    <eStructuralFeatures xsi:type="ecore:EReference" name="class1" eType="#//Class1"/>
  </eClassifiers>
</ecore:EPackage>


There are two references to Class1 and both named class1. If I transform it at the moment I get the following output:

<rdf:RDF
    xmlns:Package="http://www.package.de#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  xml:base="http://www.package.de">
  <owl:Ontology rdf:about="">
    <rdfs:label>Package</rdfs:label>
  </owl:Ontology>
  <owl:Class rdf:ID="Class2">
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:onClass rdf:resource="#Class2"/>
        <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
        >1</owl:maxCardinality>
        <owl:onProperty>
          <owl:ObjectProperty rdf:ID="class1"/>
        </owl:onProperty>
      </owl:Restriction>
    </rdfs:subClassOf>
  </owl:Class>
  <owl:Class rdf:ID="Class1">
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:someValuesFrom rdf:resource="#Class1"/>
        <owl:onProperty>
          <owl:ObjectProperty rdf:about="#class1"/>
        </owl:onProperty>
      </owl:Restriction>
    </rdfs:subClassOf>
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:someValuesFrom rdf:resource="#Class1"/>
        <owl:onProperty>
          <owl:ObjectProperty rdf:about="#class1"/>
        </owl:onProperty>
      </owl:Restriction>
    </rdfs:subClassOf>
    <rdfs:subClassOf>
      <owl:Restriction>
        <owl:onClass rdf:resource="#Class1"/>
        <owl:maxCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
        >1</owl:maxCardinality>
        <owl:onProperty>
          <owl:ObjectProperty rdf:about="#class1"/>
        </owl:onProperty>
      </owl:Restriction>
    </rdfs:subClassOf>
  </owl:Class>
  <owl:ObjectProperty rdf:about="#class1">
    <rdfs:domain rdf:resource="#Class2"/>
    <rdfs:range rdf:resource="#Class1"/>
    <rdfs:domain rdf:resource="#Class1"/>
  </owl:ObjectProperty>
  <rdf:Property rdf:about="http://www.w3.org/2002/07/owl#onClass"/>
</rdf:RDF>


Here a n ObjectProperty represents a reference. It's no longer part of the class, but an independendt concept. But I want that my two references are not not modeled into the same object, so I suppose I must give the resulting reference an unique name.

I hope this will explain my problem better.
Re: [ATL] Transformation of References with same name [message #628576 is a reply to message #628181] Thu, 23 September 2010 09:01 Go to previous messageGo to next message
Eclipse UserFriend
Le 23/09/2010 12:27, moggi a écrit :
> Hi,
>
> A simple ecore file that describes the proble ist
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="Package"
> nsURI="www.example.com" nsPrefix="pa">
> <eClassifiers xsi:type="ecore:EClass" name="Class1">
> <eStructuralFeatures xsi:type="ecore:EReference" name="class1"
> eType="#//Class1"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Class2">
> <eStructuralFeatures xsi:type="ecore:EReference" name="class1"
> eType="#//Class1"/>
> </eClassifiers>
> </ecore:EPackage>
>
>
> There are two references to Class1 and both named class1. If I transform
> [...]
> Here a n ObjectProperty represents a reference. It's no longer part of
> the class, but an independendt concept. But I want that my two
> references are not not modeled into the same object, so I suppose I must
> give the resulting reference an unique name.
>
> I hope this will explain my problem better.

I suppose your ecore file is processed as a model (with Ecore.ecore as
metamodel).
So you can transform directly each EReference into corresponding element
in ontology (I'm not familiar with ontologies):

rule EReference2ObjectProperty {
from
er : ecore:EReference
to
op : owl:ObjectProperty (
< different attributes where to store
the EClass of the "er" object >
)
}
As this, you process each reference (despite names are equals) and you
can access every element you need within the reference (type,
multiplicity,...).
--
Cordialement

Vincent MAHÉ

Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
Re: [ATL] Transformation of References with same name [message #630206 is a reply to message #628576] Fri, 01 October 2010 03:11 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I have a problem that it is the contrary !!!

An example:

input model:

Column1 contains StringDataType
Column2 contains StringDataType
Column3 contains StringDataType

output model:

Property1 with type = String
Property2 with type = String
Property3 with type = String

In this case, StringDataType are 3 different elements contained into each different column in the input model, but in output model, String is only one element referenced by the properties.

How can I define my rule to only transform one StringDataType element without using do block in my ATL code ?¿?

Thanks in advance
Miguel Llàcer
Re: [ATL] Transformation of References with same name [message #630216 is a reply to message #627019] Fri, 01 October 2010 04:04 Go to previous message
Eclipse UserFriend
The "one-to-many" pattern in ATL is quite easy, but the "many-to-one" is really hard.

Best solution to that is to filter only one of the element and to map the others to this one.

helper def  : filterStringDataType : Boolean =
StringDataType.allInstances()->first()
;

helper def : mapStringDataType : Map(StringDataType,StringDataType) =
StringDataType.allInstances()->iterate(e; res : Map(StringDataType,StringDataType) = Map{} | res.including(e,thisModule.filterStringDataType))
;

helper context StringDataType def  : filter : Boolean =
self = thisModule.filterStringDataType 
;


Then you'd have as filter on the StringDataType rule
from s : StringDataType (s.filter)


And when a string data type is used, you'd have to use mapStringDataType :
type <- thisModule.mapStringDataType(s.type)


Of course you'll probably want to complexify things by adding other types which isn't a problem with this solution.
Previous Topic:[ATL] Bug in ATL 3.0.0 final refining mode ?
Next Topic:Problem LLaunching Families2Persons Tutorial Project
Goto Forum:
  


Current Time: Fri Jul 04 04:52:03 EDT 2025

Powered by FUDForum. Page generated in 0.04796 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top