Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Using Classes created in previous rules
[ATL] Using Classes created in previous rules [message #70408] Fri, 04 January 2008 11:10 Go to next message
Eclipse UserFriend
Originally posted by: mmelia.computing.dcu.ie

Hi,

I am a bit new to ATL, so I hope this makes sense!

I am trying to transform a SKOS (an OWL vocabuarly for defining knowledge
structure) document to an ECore model, which we have defined inhouse (the
ECore metamodel allows for the definition of knowledge also - it is based
on the SKOS definition).

The first rule can create a Knowledge container class, and then call a
lazy rule to create concepts and put them into the knowledge container
class.

The next step is to create knowledgeRelationship classes, which have a
source and target. The source and target are concepts created in the
previous rule. I therefore think I need to be able to reference the rules
which have already been defined (dont i?). I have tried just using the
string from the SKOS XML but get the error:
BUILD FAILED
/home/mmelia/workspace2/CAVIAr/build.xml:22: java.lang.ClassCastException:
java.lang.String cannot be cast to org.eclipse.emf.ecore.InternalEObject

I have outlined the rules below for better understanding, I hope someone
can help. Thanks!
Mark

--
============================================================ =================
-- RULES
--
============================================================ =================
lazy rule concept2concept{
from
pt: XML!Element(
pt.name = 'skos:Concept'
)
to
inf : CAVIAr!Concept(name <-
pt.children->select(e|e.name='rdf:ID')->first().value)
}

rule Model2Graph {
from
r: XML!Root --(
--r.isUnique
--)
using{
--merge all the input models
b:Set(XML!Element) = XML!Element.allInstancesFrom('IN');
}
to
rdfs: CAVIAr!Education(
concepts <-b->select(e|e.name =
'skos:Concept')->collect(e|thisModule.concept2concept(e))

)

}

rule SKOSRelationship2conceptRelationship{
from
pt: XML!Element(
pt.name='skos:narrower'
--pt.children->select(e|e.name = 'skos:narrower')
)
to
inf : CAVIAr!ConceptRelationship(
label<-'narrowerThan'
--type <- thisModule.NARROWER
source<-pt.name
--target<-pt.children->select(e|e.name='skos:narrower')->select(e|e.name='skos:Concept')- >first().children->select(e|e.name='rdf:ID')->first().value
)
}
Re: [ATL] Using Classes created in previous rules [message #70544 is a reply to message #70408] Sun, 06 January 2008 18:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mmelia.computing.dcu.ie

Hi all,

After some hours trying to investigate what I am doing wrong here, I have
come to the opinion that resolveTemp may allow me to reference the
CAVIAr!concepts created in a previous rule. This has lead me to the
following ATL rules:

lazy rule concept2concept{
from
pt: XML!Element(
pt.name = 'skos:Concept'
)
to
inf : CAVIAr!Concept(name <-
pt.children->select(e|e.name='rdf:ID')->first().value)
}

rule Model2Graph {
from
r: XML!Root
using{
b:Set(XML!Element) = XML!Element.allInstancesFrom('IN');
}
to
rdfs: CAVIAr!Education(
concepts <-b->select(e|e.name =
'skos:Concept')->collect(e|thisModule.concept2concept(e))

)
}

rule SKOSRelationship2conceptRelationship{
from
ptRel: XML!Element(
ptRel.children->select(e|e.name = 'skos:narrower')->notEmpty()
)
to
infRel : CAVIAr!ConceptRelationship(
label<-'narrowerThan',
type <- #NARROWER,
source<-thisModule.resolveTemp(ptRel,'inf')
)
}

The rule SKOSRelationship2conceptRelationship must create a
CAVIAr!ConceptRelationship which has a reference to a CAVIAr:Concept as a
source. To do this resolveTemp is used.

Unfortunately this generates the following error:
[am3.atl] SEVERE: ****** BEGIN Stack Trace
[am3.atl] SEVERE: message: ERROR: cannot convert XML2DM : ASMModule
: class org.eclipse.m2m.atl.engine.vm.nativelib.ASMModule to EMF.
[am3.atl] SEVERE: A.main() : ??#96 null
[am3.atl] SEVERE: local variables = {null=databases!rdf:RDF,
null=Map {('rdf:RDF' , databases!rdf:RDF)}, self=XML2DM : ASMModule}
[am3.atl] SEVERE: local stack = []
[am3.atl] SEVERE: A.__exec__() : ??#18 null
[am3.atl] SEVERE: local variables = {e=TransientLink {rule =
'SKOSRelationship2conceptRelationship', sourceElements = {ptRel =
databases!skos:Concept}, targetElements = {infRel = OUT!<unnamed>},
variables = {}}, self=XML2DM : ASMModule}
[am3.atl] SEVERE: local stack = []
[am3.atl] SEVERE: A.__applySKOSRelationship2conceptRelationship(1 :
NTransientLink;) : ??#30 104:4-104:47
[am3.atl] SEVERE: local variables = {infRel=OUT!<unnamed>,
ptRel=databases!skos:Concept, link=TransientLink {rule =
'SKOSRelationship2conceptRelationship', sourceElements = {ptRel =
databases!skos:Concept}, targetElements = {infRel = OUT!<unnamed>},
variables = {}}, self=XML2DM : ASMModule}
[am3.atl] SEVERE: local stack = [OUT!<unnamed>]
[am3.atl] SEVERE: ****** END Stack Trace
[am3.atl] INFO: Execution terminated due to error (see launch
configuration to allow continuation after errors).
[am3.atl] SEVERE: ERROR: cannot convert XML2DM : ASMModule : class
org.eclipse.m2m.atl.engine.vm.nativelib.ASMModule to EMF.
[am3.atl] java.lang.RuntimeException: ERROR: cannot convert XML2DM :
ASMModule : class org.eclipse.m2m.atl.engine.vm.nativelib.ASMModule to EMF.
[am3.atl] at
org.eclipse.m2m.atl.engine.vm.SimpleDebugger.error(SimpleDeb ugger.java:185)

Anybody have any ideas what this error means - or perhaps a better way to
reference elements of the output model?

Thanks again in advance for any help.

Mark


Mark Melia wrote:

> Hi,

> I am a bit new to ATL, so I hope this makes sense!

> I am trying to transform a SKOS (an OWL vocabuarly for defining knowledge
> structure) document to an ECore model, which we have defined inhouse (the
> ECore metamodel allows for the definition of knowledge also - it is based
> on the SKOS definition).

> The first rule can create a Knowledge container class, and then call a
> lazy rule to create concepts and put them into the knowledge container
> class.

> The next step is to create knowledgeRelationship classes, which have a
> source and target. The source and target are concepts created in the
> previous rule. I therefore think I need to be able to reference the rules
> which have already been defined (dont i?). I have tried just using the
> string from the SKOS XML but get the error:
> BUILD FAILED
> /home/mmelia/workspace2/CAVIAr/build.xml:22: java.lang.ClassCastException:
> java.lang.String cannot be cast to org.eclipse.emf.ecore.InternalEObject

> I have outlined the rules below for better understanding, I hope someone
> can help. Thanks!
> Mark
Re: [ATL] Creating a reference to a created model element using an XML input mdl [message #70695 is a reply to message #70544] Mon, 07 January 2008 14:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mmelia.computing.dcu.ie

Hi,

I have a very simple example now, hopefully this will make more sense and
someone can help me.

I have the following output metamodel:
package CAVIAr {

class Concept {

attribute name : String;


}



class Relationship {

attribute source : Concept;



}
}

I want to create transform a XML model to the CAVIAr metamodel - to do
this I am using the following transformation:
rule Element2Concept{
from
pt: XML!Element(
pt.name = 'skos:Concept'
)
to
inf : CAVIAr!Concept(name <-
pt.children->select(e|e.name='rdf:ID')->first().value)
}



rule Element2RelationshipClass{
from ptRel: XML!Element(
ptRel.children->select(e|e.name = 'skos:narrower')->notEmpty()
)
to
infRel : CAVIAr!Relationship(
--need to refer to a concept that has been created by the element ptRel
in the rule Element2Class

source<-ptRel
--source<-thisModule.resolveTemp(ptRel,'inf')
)
}

The problem is in the Element2RelationshipClass transformation when I try
and create a reference to the source of the the created
CAVIAr!Relationship, which should be the XML!Element ptRel, but this does
not generate a reference to a valid concept, as can be seen from the XMI
of the generated model below:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns="platform:/resource/CAVIAr/metamodels/skos2.ecore">

<concepts name="First_Normal_Form"/>
<concepts name="Normalisation"/>
<concepts name="Fourth_Normal_Form"/>
<concepts name="Multivalued_Dependency"/>
<concepts name="BCNF"/>
<concepts name="Third_Normal_Form"/>
<concepts name="Functional_Dependency"/>
<concepts name="Second_Normal_Form"/>
<concepts name="Database_Systems"/>
<concepts name="Information_Systems"/>
<concepts name="Database_Architecture"/>
<concepts name="Three_Layer_Model"/>
<concepts name="System_Catalog"/>
<concepts name="DML"/>
<concepts name="SQL"/>
<concepts name="DDL"/>
<concepts name="SQL_Select"/>
<concepts name="Relational_Modelling"/>
<concepts name="Relational_Calculus"/>
<concepts name="Relational_Algebra"/>
<concepts name="SQL_Views"/>
<concepts name="Storage_Structures"/>
<concepts name="Indexing"/>
<concepts name="Hashing"/>
<concepts name="JDBC"/>
<concepts name="Java_Programming"/>
<concepts name="ER_Modelling"/>
<concepts name="Modelling"/>
<concepts name="Fifth_Normal_Form"/>

<ConceptRelationship source="#/1"/>
<ConceptRelationship source="#/2"/>
<ConceptRelationship source="#/3"/>
<ConceptRelationship source="#/4"/>
<ConceptRelationship source="#/5"/>
<ConceptRelationship source="#/6"/>
<ConceptRelationship source="#/7"/>
<ConceptRelationship source="#/8"/>
<ConceptRelationship source="#/9"/>
<ConceptRelationship source="#/10"/>
</xmi:XMI>
Re: [ATL] Creating a reference to a created model element using an XML input mdl [message #71555 is a reply to message #70695] Thu, 10 January 2008 11:59 Go to previous message
Eclipse UserFriend
Originally posted by: mmelia.computing.dcu.ie

Hi all,

Just solved this problem I was having - want to share the soln.

The problem was that the rule was referring to the same XML!Element - i
changed it used resolveTemp and got it working - see below

rule concept2concept{
from
pt: XML!Element(
pt.name = 'skos:Concept'
)
to
inf : CAVIAr!Concept(name <-
pt.children->select(e|e.name='rdf:ID')->first().value)
}

rule SKOSRelationship2conceptRelationship{
from
ptRel: XML!Element(
ptRel.name = 'skos:narrower'
)

to
infRel : CAVIAr!ConceptRelationship(
label<-'narrowerThan',
type <- #NARROWER,
source<-thisModule.resolveTemp(ptRel.parent,'inf')
}

Another thing i noted that you cant refer to source elements of matched
rules in the ResolveTemp helper when the matched rule source (in this case
"inf") is defined in a called rule.

Hope this helps someone.
Mark

Mark Melia wrote:


> I have the following output metamodel:
> package CAVIAr {

> class Concept {

> attribute name : String;


> }



> class Relationship {

> attribute source : Concept;



> }
> }

> I want to create transform a XML model to the CAVIAr metamodel - to do
> this I am using the following transformation:
> rule Element2Concept{
> from
> pt: XML!Element(
> pt.name = 'skos:Concept'
> )
> to
> inf : CAVIAr!Concept(name <-
> pt.children->select(e|e.name='rdf:ID')->first().value)
> }



> rule Element2RelationshipClass{
> from ptRel: XML!Element(
> ptRel.children->select(e|e.name = 'skos:narrower')->notEmpty()
> )
> to
> infRel : CAVIAr!Relationship(
> --need to refer to a concept that has been created by the element ptRel
> in the rule Element2Class

> source<-ptRel
> --source<-thisModule.resolveTemp(ptRel,'inf')
> )
> }

> The problem is in the Element2RelationshipClass transformation when I try
> and create a reference to the source of the the created
> CAVIAr!Relationship, which should be the XML!Element ptRel, but this does
> not generate a reference to a valid concept, as can be seen from the XMI
> of the generated model below:

> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xmi:XMI xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns="platform:/resource/CAVIAr/metamodels/skos2.ecore">

> <concepts name="First_Normal_Form"/>
> <concepts name="Normalisation"/>
> <concepts name="Fourth_Normal_Form"/>
> <concepts name="Multivalued_Dependency"/>
> <concepts name="BCNF"/>
> <concepts name="Third_Normal_Form"/>
> <concepts name="Functional_Dependency"/>
> <concepts name="Second_Normal_Form"/>
> <concepts name="Database_Systems"/>
> <concepts name="Information_Systems"/>
> <concepts name="Database_Architecture"/>
> <concepts name="Three_Layer_Model"/>
> <concepts name="System_Catalog"/>
> <concepts name="DML"/>
> <concepts name="SQL"/>
> <concepts name="DDL"/>
> <concepts name="SQL_Select"/>
> <concepts name="Relational_Modelling"/>
> <concepts name="Relational_Calculus"/>
> <concepts name="Relational_Algebra"/>
> <concepts name="SQL_Views"/>
> <concepts name="Storage_Structures"/>
> <concepts name="Indexing"/>
> <concepts name="Hashing"/>
> <concepts name="JDBC"/>
> <concepts name="Java_Programming"/>
> <concepts name="ER_Modelling"/>
> <concepts name="Modelling"/>
> <concepts name="Fifth_Normal_Form"/>

> <ConceptRelationship source="#/1"/>
> <ConceptRelationship source="#/2"/>
> <ConceptRelationship source="#/3"/>
> <ConceptRelationship source="#/4"/>
> <ConceptRelationship source="#/5"/>
> <ConceptRelationship source="#/6"/>
> <ConceptRelationship source="#/7"/>
> <ConceptRelationship source="#/8"/>
> <ConceptRelationship source="#/9"/>
> <ConceptRelationship source="#/10"/>
> </xmi:XMI>
Previous Topic:[M2M] Wiki document renames
Next Topic:[ATL] How to compile a library ATL file?
Goto Forum:
  


Current Time: Fri Mar 29 11:57:56 GMT 2024

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

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

Back to the top