EMF namespace URI/prefix is null - eclipse

I have to use EMF to create a EMF Generator Model from an existing ecore diagram, but it gives me namespace errors when trying to do so.
Here is is the screenshot of the two errors.
I think the error might be in the ecore file (XML), but I have no idea what to write, as I have only been using the GUI tool to create the ecore model...
My ecorediag file is here, and my ecore file is here.
I have bad experience with EMF, as it has never worked smoothly without any hiccups, and this is yet another problem, however, I am forced to use it.
I tried Googling the errors, but only 9 and 8 hits were returned, most of which did not help solve the problem.
What do I need to edit in the ecorediag or ecore file to be able to generate my EMF Generator Model?
For the record, I am using Eclipse 4.2.2.

change nsURI in to "http: ///ecore_file_name.ecore" and nsPrefix into "ecore_file_name" it woks great

The solution I found was to rewrite the whole project from scratch.
The approach was to carefully generate the genmodel for every change I made to the ecore file (adding/renaming/removing attributes/classes) to make sure nothing bad happened between any alterations to the model. By following this approach, you will be able to isolate the problem if something goes wrong.
However, I am still looking for another solution/answer other than rewriting everything.

Related

Removing annotations from a Modelica model

I'm developing a Modelica library and need to produce a document with source code listings. I'd like to be able to include the source of the Modelica models without annotations.
I could manually edit them out, but I'm looking for a more automated strategy. I'm guessing the most convenient and straightforward approach is to use some tool to save .mo files with no annotations and include those in my document (I'm using \lstinputlisting in LaTeX).
Is it possible to do this? I have access to Dymola, OpenModelica and JModelica. Dymola is obviously capable of producing such a listing, as it's able to include it in the automatically generated documentation (File > Export > HTML...). I've been looking into scripting with Dymola and OpenModelica, but haven't found a way to do this either.
JModelica seems like it could be a good option, but I don't have experience working with Python. If this is possible and someone gives me some pointers, I'm willing to look into it myself. I found a mention to a prettyprint function that might do the job, but I'm not sure where to start. I can't even find reference to that function in the latest documentation.
It would also be more convenient for me to find a way of doing it with Dymola/OpenModelica (whether through the UI or by using a script). Have I missed something?
I think you could use saveTotalModel("total.mo", MyModelName) in OpenModelica. This will strip most annotations (not ones used for code generation if I remember correctly) and pretty-print the source code including all dependencies. Then you just copy-paste the models/packages that you want to include in the listing. Or if you prefer, you can do something like the following to only include code for a particular model:
loadModel(Modelica);
loadFile("MyModel.mo");
saveTotalModel("total.mo", MyModel.A.B);
clear();
loadFile(MyModel);
str := list(MyModel.A.B);
writeFile("MyModel.A.B.listing", str);

Editing the Manifest.MF file with new plugin template wizard

I want to create a plugin template that includes a declarative service. so far, i have been following the lead of "Creating your own Eclipse-plugin", which works fine.
Then I generate the OSGI-INF/my-component.xml file in the updateModel(..) method of the MyOptionTemplateSection, which also works perfectly.
..but then I need to add an additional line to the MANIFEST.MF file of the project that I want to create, and that's where I get stuck:
Service-Component: OSGI-INF/mycomponent.xml
How can I best achieve this?
I don't see any means of inserting this in the project's model prior to generating the bundle, and if I try to access the Manifest.MF file during the updateModel(..) of my OptionTemplateSection, it isn't available yet. Before I start with executors and the likes, I was wondering if there is an elegant way to approach this; I don't think it is an unusual request, to be able to declare components in the template.
Thanks in advance!
Well, after a day of following Greg's lead, I have found a solution that is not overly elegant, but comes close enough. If anyone ever wants to change the manifest.mf file, then one has to get PDE's IBundle interface. Sadly, access to this interface in discouraged by PDE , most likely because it is still under development (I have the feeling that the PDE team is phasing out the notion of 'plugin' in favour of 'bundle', which makes sense).
Anyhow, in the updateModel(...) method of your OptionTemplateSection -or the performFinish(..) method of your NewPluginTemplateWizard- you get an IPluginModel, which is actually an IBundlePluginModelBase. The following three lines will add a Service-Component to your manifest file:
#Override
protected void updateModel(IProgressMonitor monitor) throws CoreException {
IBundlePluginModelBase mb = (IBundlePluginModelBase) model;
IBundle bundle = mb.getBundleModel().getBundle();
bundle.setHeader( "Service-Component", "OSGI-INF/component.xml" );
....
}
bundle.setHeader(key, value) allows you to include any line to your manifest file, so you can also use this to create a fragment bundle, Web-Context or a custom manifest
As I said, this solution will produce 'discouraged acccess' warnings, but personally I think this an overly restricted choice of PDE, and not so much a matter of incorrect coding.

How to use xtext and xpand togheter

I have a rather silly question. I am using xtext to define a simple dsl and Xpand to generate code.
Now I want to use xpand to read my dsl models and generate code. How can i do that?
I read lot of tutorials saying that I can simple do that by creating a new xtext project from the wizard. Then, among others, the following project will be created:
org.xtext.example.domainmodel.generator.
And inside, the generator looks like this:
src
model (place the dsl model)
templates (place the template for the code generator)
workflow (workflow file)
Then i simple run the workflow and generate the code from the dsl file. That s straightforwards and easy.
My problem is that when I create a new xtext project I dont get the org.xtext.example.domainmodel.generator. project. I only have the following four:
org.xtext.example.domainmodel
org.xtext.example.domainmodel.sdk
org.xtext.example.domainmodel.tests
org.xtext.example.domainmodel.ui
So how can i produce the org.xtext.example.domainmodel.generator file???
Which tutorials do you mean? (links please) And do they really talk about a generator project? Talking about the package org.xtext.example.domainmodel.generator inside the org.xtext.example.domainmodel project is the usual thing.
Probably not relevant to the original person who asked this :) but I had a similar problem and the reason was that in my grammar extended xbase.
When extending xbase building the mwe2 skips the generator stub generation and uses the xbase code generation which is generated instead (the antlr parser, serializer etc.)

xtend2 code generation with ecore meta-model

I created an ecore-Metamodel, a genmodel and a corresponding model.
Now I want to generate Code from this.
I found this post and wanted to implement it. I get no errors and so on, but how do I bring the CodeGenerator to generate the wanted output in a File like 'test.txt' (taken that example from the referenced question)?
Do I require a workflow file (mwe2) or do I miss something?
I only needed to run the application as Java and the code worked. I don't need any workflow or mwe2!
But appearently I still cant create the files like I can with a Generator.
I just can use a simple filewriter.

Reference Ecore model path of a different Ecore model

Here is my problem>
We currently have several Ecore models for our applications. One of the Ecore models (mainModel.ecore) has stuff that is common in all the rest of the models. So, what i want to do is have all the other models reference the contents of that one model so we do not have to constantly copy the contents of that one model into all the models every time there is a change.
Is this possible and how can I do this?
(I am very new to Ecore and still do not understand a lot of the terminology.)
EDIT:
How do i get the EcoreUtil.getRootContainer to return the the container of the loaded resource? I need to have that location so that i can resolve certain paths from that root. This may resolve my issue.
Here is what i attempted so far:
I tried "load resource..." by loading the mainModel.ecore into all the other models and deleting the local references. There were a lot of places that i had to fix after doing this and i did. After re-generating the source and trying to compile there are places where it tried accessing the "dotpath" that was local to the original file and i do not know how to change that "dotpath" to reference the "loaded resource". So it is not able to resolve those paths.
Thanks!
You'll generally get answers about EMF more readily by using the EMF newsgroup (eclipse.tools.emf) which is web accessible via
http://www.eclipse.org/forums/index.php/f/108/
Your problem isn't so clear. I don't understand how the compiled code accesses anything via a "dot path". I know if you load a resource and refer to it's contents you'll generally end up with relative paths, but those are normally resolved during loading to an absolute URI. Of course the referencing resource itself needs to be loaded with an absolute URI, but the generator does that properly...