We have defined a number of transformations over several files and we are experiencing that resolve expressions do not seem to work when the relevant mapping function is defined in a different file. We hope any of you can help us.

To illustrate the problem, a pseudo example is presented below. Consider a QVTo transformation defined in the file 'creation.qvto' as follows:

Unfortunately, we encounter that the resulting variables i and j are unresolved for each o. Possibly, I am not using the available constructs in the correct way, or even using the correct constructs. Or perhaps the scope of the resolve expressions is limited to the one file in which the involved mapping function is defined. I do hope that the latter is not the case...

My own attempts at using resolve before becoming a QVTo committer were
not good.

I found the constructs difficult to understand and the QVTo
implementation suspect. The limited capabilities of late resolution were
also unhelpful.

I found creating my own mapping Dict from input to output more
understandable for me. It was obvious what happened when and debuggable
as to what had happened.

Subsequently I tried resolve again and got on a bit better, so I'm
undecided whether my problems were user or tool related.

---

Your pseudo example is close to a complete example.

If you can convert it into a zipped project it may help you or us to
debug the problem.

Regards

Ed Willink

On 18/09/2012 14:52, Bart Theelen wrote:
> We have defined a number of transformations over several files and we
> are experiencing that resolve expressions do not seem to work when the
> relevant mapping function is defined in a different file. We hope any
> of you can help us.
>
> To illustrate the problem, an example is presented below. Consider a
> QVTo transformation defined in the file 'creation.qvto' as follows:
>
>
> transformation Creation(in I: InModel, out O: OutModel);
>
> main() {
> I.objectsOfType(InModel::Bar)->map create()
> }
>
> mapping InModel::Bar::create() : OutModel::Foo { }
>
>
> We are using the above Creation transformation in a different file as
> follows:
>
>
> import Creation;
>
> transformation Transform(in I: InModel, out O: OutModel);
>
> main() {
>
> new Creation(I,O).transform();
> O.objectsOfType(OutModel::Foo)->forEach(o) {
> var i := o.invresolveone(InModel::Bar);
> var j := o.invresolveoneIn(InModel::Bar::create, InModel::Bar)
> }
> }
>
>
> Unfortunately, we encounter that the resulting variables i and j are
> unresolved for each o. Possibly, I am not using the available
> constructs in the correct way, or even using the correct constructs.
> Or perhaps the scope of the resolve expressions is limited to the one
> file in which the involved mapping function is defined.
>
> Can anyone help?

Currently, each instantiated transformation which is called via transform() gets its own individual trace. In order to see the results of the transform() execution on the trace during resolution, it would be necessary to reuse the current trace for the instantiated transformation in the QVTo implementation (cf. bug 392153). A fix has been proposed but integration is pending.

Another remark: you are importing 'Creation' without the 'access' keyword. This leads to the 'extends' keyword being used implicitly from the QVTo implementation, i.e. your transformation inherits from 'Creation'. When running an instance of your base transformation, an implicit instance of 'Creation' already exists due to the inheritance. Then, you once again instantiate 'Creation' (this time explicitly) and execute it via the call to transform().

This mixture of inheritance and instantiation seems a little bit unforeseen. The normal way would be to use only inheritance and call any mappings directly without a call to transform(), or to specify the 'access' keyword and use the transform() call. However, only in the first case, the mapping 'create' is accessible for resolution due to the inheritance.