Resolving cross-references in standalone [message #977547] |
Fri, 09 November 2012 11:19 |
Quentin Boucher Messages: 27 Registered: July 2012 |
Junior Member |
|
|
Hello!
I'm currently trying to export my model files to XMI in standalone. My language (called FCSS) refers to elements of another language (TVL). In the editor, cross references are right. However, when I try to generate the XMI, I cannot resolve them and get links like #xtextLink_::0.1.1.0::0::/1"/. I have read a lot of threads from this forum but was not able to solve my problem.
Here is my current export method, inspired by a previous thread:
public class Main {
public static void main(String[] args) throws IOException {
// register the TVLPackage to ecore
EPackage.Registry.INSTANCE.put(TVLPackage.eNS_URI, TVLPackage.eINSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("tvl", new XMIResourceFactoryImpl());
// register the resourceserviceprovider
new TVLSupport().registerServices(true);
// register the dsl
Injector injector = new FCSSStandaloneSetup().createInjectorAndDoEMFRegistration();
// load all model file to the resourceset
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
Resource fcssResource = resourceSet.getResource(URI.createURI("/Users/Quentin/runtime-New_configuration/Test/Tune.fcss"), true);
Resource tvlResource = resourceSet.getResource(URI.createURI("/Users/Quentin/runtime-New_configuration/Test/Tune.tvl"), true);
// work with the resources (the elements come from Tune.tvl)
fcssResource.load(null);
Resource xmiResource = resourceSet.createResource(URI.createURI("/Users/Quentin/runtime-New_configuration/Test/Tune.xmi"));
xmiResource.getContents().add(fcssResource.getContents().get(0));
try {
xmiResource.save(null);
} catch (IOException e) {
e.printStackTrace();
}
}
}
But, when I try to launch it, I get a Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.xml.sax.SAXParseException: Content is not allowed in prolog. at line Resource tvlResource = resourceSet.getResource(URI.createURI("/Users/Quentin/runtime-New_configuration/Test/Tune.tvl"), true);
The code of TVLSupport is the following:
import org.eclipse.xtext.resource.generic.AbstractGenericResourceSupport;
import com.google.inject.Module;
public class TVLSupport extends AbstractGenericResourceSupport {
@Override
protected Module createGuiceModule() {
return new TVLRuntimeModule();
}
}
Do you have any idea of the sources of my problems?
Thank you very much for your help!
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03851 seconds