|
Re: [QVTo] Transformation from one to N models [message #524642 is a reply to message #523154] |
Thu, 01 April 2010 16:26 |
Sergey Boyko Messages: 171 Registered: July 2009 |
Senior Member |
|
|
Hi Pablo ,
Which version of QVTo do you use?
There was bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=287711 that
led to empty result of
inModel.rootObjects()[model::SomeType]
in case objects of that type had eContainer()!=null (like in your case).
As that bug was fixed usual parameterless main() should work.
Regards,
Sergey
Pablo Parra wrote:
> Hi all,
>
> I'm facing a problem regarding model transformation with QVTo and I
> don't know how to face it. The problem is as follows:
>
> I have one input model that has an "a priori" undetermined number of
> elements of a certain type. This is:
>
> <rootElement>
> <nodeList>
> <node1>
> <node2>
> ...
> <noden>
> </nodeList>
>
> The thing is that I have to create one output model from each of the
> nodeN elements. The first solution that came into my mind has been to
> create a transformation from the original input model to the output
> model. That transformation contains a mapping between the nodeN element
> type to the output model root type. With the TransformationExecutor
> class, I call it for each of the elements of the node list, like this:
>
> Resource inputRes = ...
> NodeList nodeList = ...
> ..
> ExecutionContextImpl context = new ExecutionContextImpl();
> TransformationExecutor executor = new
> TransformationExecutor(transformationURI);
>
> for (Iterator<NodeElement> i = nodeList.iterator; i.hasNext(); )
> {
> Node node = i.next();
> Resource outputRes = ...
> BasicModelExtent input = new BasicModelExtent();
> input.add(node);
>
> ModelExtent output = new BasicModelExtent();
>
> ExecutionDiagnostic diagnostic = executor.execute(context, input,
> output);
>
> if(diagnostic.getSeverity() == Diagnostic.OK) {
> ...
> }
> }
>
> The problem with this solution is that the transformation does not work
> unless I put input and output parameters to the main mapping entry
> operation. My first approach was not to put them and to call the mapping
> in a way similar to this one:
>
> main()
> {
> inModel.rootObjects()[model::NodeElementType]->map
> NodeElement2OutputModel;
> }
>
> But it does not work (or at least it didn't work for me): it does not
> detect any input element. What I did then was to put parameters to the
> main mapping entry:
>
> main(in node : inputModel::NodeElementType, out outModel : outputModel)
> {
> outModel := node.map NodeElement2OutputModel;
> }
>
> This works, but it outputs a warning message saying that using
> parameters in the main entry is deprecated :( so i don't know if it
> will work in the future...
>
> I don't know if there is another way to approach the problem or if I'm
> missing something.. any help would be very much appreciated :)
>
> Thank you very much in advance.
>
> Pablo Parra.
|
|
|
Powered by
FUDForum. Page generated in 0.03054 seconds