Ismail Zine Messages: 11 Registered: February 2012
Junior Member
Hi,
And how can I get an XMI model from a DSL textual file?
You should know that I don't have the .generator project ( I don't have this option when creating an xtext project )
did you try to read the dsl file, resolve the cross references and add
the contents of the parsed resource to a newly created XMI resource? I
assume you are familiar with the EMF resource concept?
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 16.02.12 14:54, schrieb Ismail Zine:
> Hi,
>
> And how can I get an XMI model from a DSL textual file?
> You should know that I don't have the .generator project ( I don't have
> this option when creating an xtext project )
>
> Thanks,
Ismail Zine Messages: 11 Registered: February 2012
Junior Member
I found something interesting in the generator workflow that could help to save the xtext resource as xmi..
<component file="my/textual/dsl/parser/Parser.oaw">
<metaModel idRef="mm"/>
<outputSlot value="mymodel"/>
<modelFile value="person.dsl"/>
</component>
the problem is that The Modeling Workow Engine 2 syntax is different from the the modeling workflow engine, and when I try to write like :
component = oaw.emf.XmiWriter {
modelFile = "out.xmi"
inputSlot = "mymodel"
}
the following error appears : Couldn't resolve reference to JvmType 'oaw.emf.XmiWriter'
Ismail Zine Messages: 11 Registered: February 2012
Junior Member
Thanks for your response, I have 1.1.1 version
there is no documentation of org.eclipse.emf.mwe.utils.Writer, which is weird!!
do u know how can I write the parser component ( the file property !! )
<component file="my/textual/dsl/parser/Parser.oaw">
<metaModel idRef="mm"/>
<outputSlot value="mymodel"/>
<modelFile value="person.dsl"/>
</component>
using the Modeling Workow Engine 2.
Hi once more oAW Xtext != Eclipse Xtext => Trying to translate a oAW Xtext Workflow is of limited sense.
there is the org.eclipse.xtext.mwe.Reader or the org.eclipse.xtext.mwe.UriBasedReader
for that
Ismail Zine Messages: 11 Registered: February 2012
Junior Member
Hi,
this is driving me crazy!! I'm trying this which, I found in xtext 2.1 documentation:( to read the dsl file and load it as a xtextResource )
Injector injector = new GaCodeModelStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
URI uri = URI.createURI("person.cm");
Resource xtextResource = resourceSet.getResource(uri, true);
but it throws this exception :
Exception in thread "main" java.lang.RuntimeException: Cannot create a resource for 'person.cm'; a registered resource factory is needed
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:394)
at org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23)
so I add this to the code
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(
Resource.Factory.Registry.DEFAULT_EXTENSION,
new XMIResourceFactoryImpl());
it throws
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:315)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
at org.eclipse.xtext.resource.SynchronizedXtextResourceSet.getResource(SynchronizedXtextResourceSet.java:23)
at geneauto.models.ModelStandaloneSetup.main(ModelStandaloneSetup.java:50)
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1039)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:242)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1511)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1290)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:270)
... 3 more
in the second eclipse, when I try to open the dsl file using a sample reflective ecore editor as shown in the xtext website, it gives the same exception!! ( content is not allowed in prolog )