My model to model transformation doesn´t work [message #555612] |
Fri, 27 August 2010 07:14  |
Eclipse User |
|
|
|
Hello I´m new in model to model transformation.
I´ve done a qvto file and this doesnt work.
this is my code:
modeltype MMSCXMLWeb 'strict' uses 'http://MMSCXMLWeb';
modeltype SCXMLw3c 'strict' uses'http://www.w3.org/2005/07/scxml';
transformation MMW2SCXML(in inModel:MMSCXMLWeb, out outModel:SCXMLw3c);
property transitions : Set(Transition) =null;
main(){
inModel.rootObjects()[SCXML]->map toSCXML();
}
mapping MMSCXMLWeb::SCXML::toSCXML() : SCXMLw3c::ScxmlScxmlType
{
name =self.Name;
initial1:=self.Initial;
state +=self.ApplicationState.map ApptoState();
}
mapping MMSCXMLWeb::Application::ApptoState() : SCXMLw3c::ScxmlStateType{
init{
this.transitions=self.GetTransitions();
self.Transition=this.transitions->select(Source_State = self);
}
id = self.ID;
initial1= self.Initial;
transition +=self.Transition.map toScxmlTransitions();
state += self.Generic.map toSCXMLStates();
state += self.OP.map OPToScxmlStates();
}
mapping MMSCXMLWeb::Generic::toSCXMLStates() : SCXMLw3c::ScxmlStateType{
init{
self.Transition=this.transitions->select(Source_State = self);
result := object SCXMLw3c::ScxmlStateType{
id=self.ID;
initial1=self.Initial;
transition+= self.Transition.map toScxmlTransitions();
}
}
}
mapping MMSCXMLWeb::OP::OPToScxmlStates() : SCXMLw3c::ScxmlStateType{
init{
self.Transition=this.transitions->select(Source_State = self);
result := object SCXMLw3c::ScxmlStateType{
id=self.ID;
initial1=self.Initial;
transition += self.Transition.map toScxmlTransitions();
state += self.View.map ViewToScxmlStates();
}
}
}
mapping MMSCXMLWeb::View::ViewToScxmlStates() : SCXMLw3c::ScxmlStateType{
init{
self.Transition=this.transitions->select(Source_State = self);
result := object SCXMLw3c::ScxmlStateType{
id=self.ID;
initial1=self.Initial;
transition += self.Transition.map toScxmlTransitions();
}
}
}
mapping MMSCXMLWeb::Transition::toScxmlTransitions() : SCXMLw3c::ScxmlTransitionType{
init{
result:=object SCXMLw3c::ScxmlTransitionType{
cond=self.Cond;
event1=self.Event;
target=self.Target;
}
}
}
query MMSCXMLWeb::State::GetTransitions() : Set(MMSCXMLWeb::Transition){
return self.Transition;
}
Does anyone how to make this work??
Is there any guide for model to model transformation?
Thanks, Pablo
|
|
|
Re: My model to model transformation doesn´t work [message #555621 is a reply to message #555612] |
Fri, 27 August 2010 07:57   |
Eclipse User |
|
|
|
Originally posted by: dhendriksREMOVE_THIS.tueREMOVE.THIS.nl
Hello Pablo,
first things first. In the future, please prefix QVTo related posts with
[QVTo].
> I´ve done a qvto file and this doesnt work.
> Does anyone how to make this work??
Secondly, this kind of statements don't give much indication where to
look. What doesn't work. What did you do, what happened, and what did
you expect to happen?
OK, now to the real issue. I see some problems with your source code:
> name =self.Name;
I think you mean:
name :=self.Name;
you seem to use = instead of := a lot. I think you get syntax errors
that way, right?
Furthermore, let's look at this:
> init{
> this.transitions=self.GetTransitions();
> self.Transition=this.transitions->select(Source_State = self);
> }
assigning self.Transition is not allowed, as self refers to an input
element (a part of 'in inModel:MMSCXMLWeb'), and that is read-only. You
are only allowed to create and modify output elements.
Then there is this:
> query MMSCXMLWeb::State::GetTransitions() :
> Set(MMSCXMLWeb::Transition){
> return self.Transition;
> }
It doesn't make sense. Can't you just use self.Transition everywhere you
use that query? Wouldn't that be easier?
Also, I don't know what the transformation is supposed to do, so I can't
comment on the whether your general approach would work. I do have some
doubts regarding the 'transitions' property. You seem to assign it with
source objects, and then use it locally in the same mapping where you
assign it. Can't you just eliminate that property entirely?
Finally "mapping MMSCXMLWeb::Generic::toSCXMLStates()". I think you can
get rid of the init, the explicit assignment to result, and the explicit
creation of the target element.
Hope this helps,
Dennis
Pablo Nieto wrote:
> Hello I´m new in model to model transformation.
> I´ve done a qvto file and this doesnt work.
>
> this is my code:
>
> modeltype MMSCXMLWeb 'strict' uses 'http://MMSCXMLWeb';
> modeltype SCXMLw3c 'strict' uses'http://www.w3.org/2005/07/scxml';
> transformation MMW2SCXML(in inModel:MMSCXMLWeb, out outModel:SCXMLw3c);
>
> property transitions : Set(Transition) =null;
>
> main(){
> inModel.rootObjects()[SCXML]->map toSCXML();
> }
>
>
> mapping MMSCXMLWeb::SCXML::toSCXML() : SCXMLw3c::ScxmlScxmlType
> {
> name =self.Name;
> initial1:=self.Initial;
> state +=self.ApplicationState.map ApptoState();
>
> }
>
> mapping MMSCXMLWeb::Application::ApptoState() : SCXMLw3c::ScxmlStateType{
>
> init{
> this.transitions=self.GetTransitions();
> self.Transition=this.transitions->select(Source_State = self);
> }
> id = self.ID;
> initial1= self.Initial;
> transition +=self.Transition.map toScxmlTransitions();
> state += self.Generic.map toSCXMLStates();
> state += self.OP.map OPToScxmlStates();
>
> }
>
> mapping MMSCXMLWeb::Generic::toSCXMLStates() : SCXMLw3c::ScxmlStateType{
> init{
> self.Transition=this.transitions->select(Source_State = self);
> result := object SCXMLw3c::ScxmlStateType{
> id=self.ID;
> initial1=self.Initial;
> transition+= self.Transition.map toScxmlTransitions();
>
> }
> }
>
> }
>
> mapping MMSCXMLWeb::OP::OPToScxmlStates() : SCXMLw3c::ScxmlStateType{
> init{
> self.Transition=this.transitions->select(Source_State = self);
> result := object SCXMLw3c::ScxmlStateType{
> id=self.ID;
> initial1=self.Initial;
> transition += self.Transition.map toScxmlTransitions();
> state += self.View.map ViewToScxmlStates();
>
>
> }
> }
> }
>
> mapping MMSCXMLWeb::View::ViewToScxmlStates() : SCXMLw3c::ScxmlStateType{
> init{
> self.Transition=this.transitions->select(Source_State = self);
> result := object SCXMLw3c::ScxmlStateType{
> id=self.ID;
> initial1=self.Initial;
> transition += self.Transition.map toScxmlTransitions();
> }
> }
> }
> mapping MMSCXMLWeb::Transition::toScxmlTransitions() :
> SCXMLw3c::ScxmlTransitionType{
> init{
> result:=object SCXMLw3c::ScxmlTransitionType{
> cond=self.Cond;
> event1=self.Event;
> target=self.Target;
> }
> }
> }
>
>
>
> query MMSCXMLWeb::State::GetTransitions() : Set(MMSCXMLWeb::Transition){
> return self.Transition;
> }
>
>
> Does anyone how to make this work??
>
> Is there any guide for model to model transformation?
>
> Thanks, Pablo
>
>
|
|
|
|
|
|
|
|
|
Re: My model to model transformation doesn´t work [message #556379 is a reply to message #556343] |
Wed, 01 September 2010 02:06   |
Eclipse User |
|
|
|
Originally posted by: dhendriksREMOVE_THIS.tueREMOVE.THIS.nl
Hello Pablo,
> I can´t execute the qvto file.
> It´s because the asignation has difrent types:
> Java.util.list and String
Java.utils.list does not seem like a type that QVTo would generally use.
I would have expected one of the OCL types like Sequence, OrderedSet,
Set, or Bag. How did you end up with java.util.List? Did you not define
the language using an Ecore?
What does QVTo indicate as the type of 'target'?
Note that if it is a QVTo List type, it is mutable type. In that case
you can take a look at section 8.3.8 of the QVT standard. In particular
8.3.8.1 explains the add operation, which would be something like:
target.add(self.Source_State.ID);
If none of this works, maybe you can post the entire transformation, so
that we have more information, and more context?
Dennis
Pablo Nieto wrote:
> the code doesn´t compile.
>
> I can´t execute the qvto file.
>
> It´s because the asignation has difrent types:
>
> Java.util.list and String
>
> Thanks
|
|
|
|
|
|
|
Re: My model to model transformation doesn´t work [message #556646 is a reply to message #556631] |
Thu, 02 September 2010 04:06  |
Eclipse User |
|
|
|
Hi Pablo
Please supply the model; just because it's standard to you doesn't mean
we all know it. We need to see your declaration of 'target'.
oclAsType(OrderedSet(String)) is not valid OCL; there is an OMG issue to
make it valid and an MDT/OCL bug
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=299957) to support it.
target.oclAsType(OrderedSet(String)) is very suspect. You are using a
non-Collection operation on target which presumably must be a Collection
to support append.
Perhaps you just need "->".
Regards
Ed Willink
On 02/09/2010 08:34, Pablo Nieto wrote:
> Hello,
> The problem is that the model with the list element is a W3C standard
> (SCXML) and some elemet´s atributes are of List type.
> So I can´t modify this model.
>
> I think that the error occurs because QVTo doesn´t recognize the List type.
>
> this is the mapping method:
>
> mapping MMSCXMLWeb::Transition::toScxmlTransitions() :
> SCXMLw3c::ScxmlTransitionType{
> init{
> result:=object SCXMLw3c::ScxmlTransitionType{
> cond:=self.Cond;
> event1:=self.Event;
> //target:=self.Target;
> result.target.oclAsType(OrderedSet(String))->append(self.Target_State.ID);
>
>
> }
> }
> }
>
> Thanks
|
|
|
Powered by
FUDForum. Page generated in 0.10899 seconds