|
Re: Serialize selected DSL model objects dynamically [message #1750650 is a reply to message #1750640] |
Fri, 23 December 2016 19:52  |
|
can you please explain what you actually want to do?
what is input and what is the expected output?
if you simply want to serialize a model the following pseudo code should work.
public class Main {
public static void main(String[] args) throws IOException {
Injector i = new MyDslStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = i.getInstance(ResourceSet.class);
Resource r = rs.createResource(URI.createURI("demo.mydsl"));
ReqSpecs specs = MyDslFactory.eINSTANCE.createReqSpecs();
ReqSpec spec1 = MyDslFactory.eINSTANCE.createReqSpec();
spec1.setName("MySpec1");
specs.getElements().add(spec1);
StructuredStatement ss = MyDslFactory.eINSTANCE.createStructuredStatement();
ss.setSubject("MySubj1");
Predicate pred = MyDslFactory.eINSTANCE.createPredicate();
pred.setObject("MyObject");
ss.setPredicate(pred);
spec1.setStatement(ss);
// .....
r.getContents().add(specs);
r.save(SaveOptions.defaultOptions().toOptionsMap());
}
}
Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Powered by
FUDForum. Page generated in 0.01894 seconds