public static void main(String args[]) { // Setup for "original" Ecore MM org.xtext.example.mydsl.anyfeature.MyDslStandaloneSetup.doSetup(); AnyfeaturePackage.eINSTANCE.eClass(); EObject eobject = createEObject("http://example.com/example-with-anyfeature", "Properties"); System.out.println(eobject); printAttributeValues(eobject); }
/** * Create a output model file from a given input model file Note: The metamodel is considered to * be already registered * * <p>Possible input: XMI, XML, DSL Possible output: XMI, XML, DSL * * @param inputModelURI input model file location (URI) * @param outputModelURI output model file location (URI) * @param dslFileExtension TODO * @throws Exception */ public void buildOutput(URI inputModelURI, URI outputModelURI, String dslFileExtension) throws Exception { // Standalone Setup if used in non-plugin project MyDslStandaloneSetup.doSetup(); AnyfeatureadaptedPackage.eINSTANCE.eClass(); // instead of manually registering DSML // Setup for "original" Ecore MM org.xtext.example.mydsl.anyfeature.MyDslStandaloneSetup.doSetup(); AnyfeaturePackage.eINSTANCE.eClass(); Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE; Map<String, Object> m = reg.getExtensionToFactoryMap(); m.put("xml", new XMLResourceFactoryImpl()); // create the resource set and add extended meta data to read/write options ResourceSet resourceSet = new ResourceSetImpl(); if (inputModelURI.fileExtension().equals(dslFileExtension) && outputModelURI.fileExtension().equals("xmi")) { // DSL --> XMI fromDSLtoXMI(inputModelURI, outputModelURI, resourceSet); } else if (inputModelURI.fileExtension().equals("xmi") && outputModelURI.fileExtension().equals(dslFileExtension)) { // XMI --> DSL fromXMItoDSL(inputModelURI, outputModelURI, resourceSet); } else if (inputModelURI.fileExtension().equals("xmi") && outputModelURI.fileExtension().equals("xml")) { // XMI --> XML (Serializer) fromXMItoXML(inputModelURI, outputModelURI, resourceSet); } else if (inputModelURI.fileExtension().equals("xml") && outputModelURI.fileExtension().equals("xmi")) { // XML --> XMI (De-Serializer) throw new Exception("NOT YET IMPLEMENTED!"); } } // buildOutput