emfjson / ecore.js Goto Github PK
View Code? Open in Web Editor NEWEcore for JavaScript
Home Page: https://emfjson.github.io/ecore.js/
License: Eclipse Public License 1.0
Ecore for JavaScript
Home Page: https://emfjson.github.io/ecore.js/
License: Eclipse Public License 1.0
Hi,
It seems that EAnnotation is not supported.
Do you plan to add it?
Thanks
I forked this repo and am trying to run Grunt to prepare the distribution, but alas... Could you create some docu on that?
Opposite references are not supported.
As a test we loaded Ecore.ecore and discovered a number of issues. The main issue among these appears to be a lack of support for generics. That is, the follow cannot be loaded:
There are a number of attributes which are not parsed as well but those can be put forth as a separate issue.
The XMI parser fails to parse an XMI file that contains multiple instances in the same resource. The parser returns TypeError: Cannot read property 'eClass' of undefined in 'onopentag'. This is essentially the XMI version of Pull Request #4. We have constructed a potential solution and will submit after testing is complete.
Hi,
After of the support of EAnnotation, could you also add the XML serialization/unserialization (EMF created from XSD)?
It is very useful when one could not use XMI.
Thanks
Hi,
Am using Xtext + Xtend and have implemented a DSL with code generation.
I want to post an emfObject from Xtend to a Javascript server.
Can you please let me know how to do this ?
They should be supported as EFloatObject.
Since emfjson-jackson allows to minimize the use of type information during serialization (see emfjson/emfjson-jackson#93 and emfjson/emfjson-jackson@18059c9) ecore.js is unable to read models written using this version of emfjson-jackson.
The parser skips a few attributes that seem to be used in many EMF xmi files such as "xmi:id" and "href". Do you have any suggestions on how to get this loaded for instance of models?
The model design like below:
<eClassifiers xsi:type="ecore:EClass" name="Node">
<eStructuralFeatures xsi:type="ecore:EReference" name="properties" eType="#//Property"
containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Property">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>``
one Node has one property
I use
node.set("properties", property)
to set a property instance to node
but how delete the property instance or how set null to the node.properties
Hi!
I have to duplicate an EObject (only the EObject: not the EObjects it contains) in one of my functions.
Can you please explain how to proceed or give an example?
The deserialization of a ecore metamodel (.ecore file) doesn't work.
I have an error at Ecore.js (ligne 1882, col. 32) TypeError: eObject is undefined
var resourceSet = Ecore.ResourceSet.create();
var resource = resourceSet.create({ uri: '/library' });
var metaModel="<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI\" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance\" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore\" name="ecoreEvaluation" nsURI="http://www.example.org/ecoreEvaluation\" nsPrefix="ecoreEvaluation">
..../ecore:EPackage"
resource.parse(metaModel,Ecore.XMI);
I'm trying to read an Ecore model
var Ecore = require('ecore');
var fs = require('fs');
var resourceSet = Ecore.ResourceSet.create();
var resource = resourceSet.create({uri : '/machin'});
var metamodel = fs.readFileSync('MyMetaModel.ecore', 'utf8');
resource.parse(metamodel, Ecore.XMI);
and I get this message
<?xml version="1.0" encoding="UTF-8"?>
^
SyntaxError: Unexpected token <
at Object.parse (native)
at Object.Ecore.JSON.parse (/home/julien/tmp/test/node_modules/ecore/dist/ecore.js:1679:25)
at Ecore.Resource.Ecore.EClass.create.eOperations._ [as parse] (/home/julien/tmp/test/node_modules/ecore/dist/ecore.js:1970:32)
at Object.<anonymous> (/home/julien/tmp/test/test.js:183:10)
at Module._compile (module.js:425:26)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:457:10)
at startup (node.js:138:18)
It seems that the parser is not taking into account the Ecore.XMI
parameter.
Am I doing something wrong ? Any suggestion ?
I'm using "ecore": "^0.11.0"
The Example from http://emfjson.org/ecore.js/#resources does not work:
var Ecore = require('ecore');
var resourceSet = Ecore.ResourceSet.create();
resourceSet.fetch();
Error:
resourceSet.fetch();
^
TypeError: resourceSet.fetch is not a function
... stack trace
EChar should be added among the datatypes
While doing a load of an XMI instance file that conforms to an XMI ecore, when the class has a reflexive relationship, is not abstract, and there are subclasses:
We have identified a potential fix for consideration and will submit a pull request after we finish updating the test cases and check for any other side effects.
When trying to parse an XMI instance file that contains an eObject attribute that is stored as an XMI element, the parser attempts to create a reference instead of detecting that the XMI element is an eObject attribute. For instance, the following XMI:
<?xml version="1.0" encoding="UTF-8"?>
<TestModel:Simple xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:TestModel="http://www.example.org/TestModel" name="stringTest" newString="A string."/>
could be stored as
<?xml version="1.0" encoding="UTF-8"?>
<TestModel:Simple xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:TestModel="http://www.example.org/TestModel" name="stringTest">
<newString>A string.</newString>
</TestModel:Simple>
when the second variant is used the parser attempts to create an element and throws the following exception:
/home/user/git/ecore.js/dist/ecore.xmi.js:291
var eOperations = eClass.get('eOperations').array();
^
TypeError: Cannot read property 'array' of undefined
at eAllOperations (/home/user/git/ecore.js/dist/ecore.xmi.js:291:48)
at initOperations (/home/user/git/ecore.js/dist/ecore.xmi.js:308:23)
at new EObject (/home/user/git/ecore.js/dist/ecore.xmi.js:188:5)
at Object.Ecore.create (/home/user/git/ecore.js/dist/ecore.xmi.js:76:19)
at Object.parser.onopentag (/home/user/git/ecore.js/dist/ecore.xmi.js:2640:55)
at emit (/home/user/git/ecore.js/node_modules/sax/lib/sax.js:640:35)
at emitNode (/home/user/git/ecore.js/node_modules/sax/lib/sax.js:645:5)
at openTag (/home/user/git/ecore.js/node_modules/sax/lib/sax.js:841:5)
at Object.write (/home/user/git/ecore.js/node_modules/sax/lib/sax.js:1291:15)
at Object.Ecore.XMI.parse (/home/user/git/ecore.js/dist/ecore.xmi.js:2730:16)
The Ecore.XMI.to function does not escape XML special characters when outputting attribute values.
I want to use the parent type to do the validator and config, will it be supported or not
Hi
The documentation on http://emfjson.org/ecore.js/ is really useful.
However, unless I am overlooking something, it shows how to create a package, and how to create various EObjects - but not how to add the EObjects to a package.
Eg, how does one add the Library object to the LibraryPackage?
Can someone please describe how to do this?
Thanks
Two cases of parsing invalid models/instance XMI were not being caught:
Initial error throws have been added to our repo in the resolve references and parse routines that detect the undefined items which cause silent discarding. Related tests have also been added.
It appears that contained instances of a nested relation are displayed as references when calling resource.to(Ecore.JSON) instead of being displayed inline. The problem appears to be caused by the feature.get('containment') returning the string "true" instead of the boolean true in resource.js in the processFeature nested function of Ecore.JSON.to.
To demonstrate the problem, type:
git clone https://github.com/CohesionForce/ecore.js.git
cd ecore.js
npm install
grunt build
cd examples/xmi_node
node simpleTest.js TestModel.ecore test2.testmodel
You will recieve the following output:
::: JSON Dump of test2.testmodel
{ eClass: 'uri-TestModel.ecore#//Simple',
name: 'SimpleTest',
info:
[ { '$ref': '//@info.0', eClass: 'uri-TestModel.ecore#//Info' },
{ '$ref': '//@info.1', eClass: 'uri-TestModel.ecore#//Info' },
{ '$ref': '//@info.2', eClass: 'uri-TestModel.ecore#//Info' } ] }
Instead of the expected:
::: JSON Dump of test2.testmodel
{ eClass: 'uri-TestModel.ecore#//Simple',
name: 'SimpleTest',
info:
[ { eClass: 'uri-TestModel.ecore#//Info',
value: '1',
name: 'Info 1' },
{ eClass: 'uri-TestModel.ecore#//Info',
value: '2',
subInfo:
[ { eClass: 'uri-TestModel.ecore#//SubordinateInfo',
name: 'Sub 2-1' },
{ eClass: 'uri-TestModel.ecore#//SubordinateInfo',
test: 'true',
name: 'Sub 2-2' },
{ eClass: 'uri-TestModel.ecore#//SubordinateInfo',
name: 'Sub 2-3' } ],
name: 'Info 2' },
{ eClass: 'uri-TestModel.ecore#//Info',
value: '3',
name: 'Info 3' } ] }
The regex wsexp = / *(.*) +\n/g
is very slow if there are attributes that have a large amount of white space (>500 spaces) somewhere between ">" and "<".
It seems that this specific case is not yet handled.
When using the XMI variant of ecore.js with node.js, the require directive looks like ecore = require('ecore/dist/ecore.xmi');
in place of the usual ecore = require('ecore');
It would be better to support symetrically ecore = require('ecore.xmi');
Hello,
first of all i want to thank you for such a wonderful project, great job. I am new to javascript development and as a native java developer i would really appreciate a typescript version of this framework. Are there any plans for converting ecore.js to typescript?
I am looking forward to hearing from you. Thank you in advance.
Best reagrds
Mehmet
Hello
Does EmfJson have any relationship to http://som-research.uoc.edu/tools/emf-rest/ ? Or are these two separate projects that are trying to achieve a similar thing?
Does EmfJson generate javascript classes from an ecore model?
Thanks
I'm trying to use emfjson to serialize an ECore model which contains annotations to json and want to deserialize it using ecore.js. Unfortunately the key/value of the details are null after deserialization.
When checking, it looks like that:
EMFJson uses this format to serialize Annotations (copied from AnntationTest expectation):
{"eClass":"http://www.eclipse.org/emf/2002/Ecore#//EClass","name":"Foo","eAnnotations":
[{"source":"source","details":{"displayName":"value"}}]}
ecore.js however serializes and deserializes like that:
details: [
{
eClass:"http://atest.com#//EStringToStringMapEntry"
key:"key1"
value:"value1"
}
]
Are there any options to customize that? What would be the suggested format? The EMFJson format?
While it is useful for it to throw an error for undefined eClasses during XMI parsing, it is also useful to be able to toggle this behavior to enable loading of troublesome files for debugging purposes.
I will be pushing a change to our repo momentarily that adds such a toggle and implements it in simpleTest.js.
Is there way to generate the model from ecore
+ genmodel
files? Is there maybe a supporting library to do this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.