On the fly XText model deserialization

233 Views Asked by At

I have a UML model having OpaqueActions containing text conform to an XText Grammar/MetaModel. I am turning the UML model into text by means of an ACCELEO transformation. I'd like to invoke from the ACCELEO script a Java service which takes as input the text in the opaque actions within the model and provides as output the root element of the related model so that I can use it seamlessly from ACCELEO.

To this end I need to define a Java class with a method which: takes as parameter a String, invokes XTEXT, parses the text and, if it is correct, produces a related EMF model. Suppose the text is OCL (It isn't but I guess the procedure is the same), how would you do that?

1

There are 1 best solutions below

0
On

You could try to load the OpaqueActions as the content of a resource in the resource set that holds the currently processed model. That will return the AST for that string.