Download Ecore.js from dist/ folder, and include it in your html along with underscore.js.
<script src="underscore.js"></script><script src="ecore.js"></script>
Alternatively you can use the dependency manager Bower to install Ecore.js in your project.
bower install ecore
Ecore.js is available on npm and can be use as a Node module. To install it simply use the following command from your terminal:
npm install ecore
Importing Ecore.js in a Node module is done as follow:
var Ecore = require('ecore');
// Resources contain model elements and are identified by a URI.var resourceSet = EcoreResourceSet;var resource = resourceSet;// EClass are used to define domain elements, they are identified// by name and a set of structural features (attributes and references).var User = EcoreEClass;// EPackages represent namespaces for a set of EClasses.// It's properties name, nsURI and nsPrefix must be set.var SamplePackage = EcoreEPackage;// Packages must be added directly to the model's Resource.resource;
Model Elements can also be created separately.
var User = EcoreEClass;var User_name = EcoreEAttribute;var User_friends = EcoreEReference;User;User;
var u1 = User;var u2 = User;u1;u1;
JSON is the default serialization format supported by ecore.js. The JSON format is described here and looks like this:
"eClass" : "/model.json#//User""name" : "u1""friends" :"$ref" : '/u2.json#/' eClass: '/model.json#//User'"$ref" : '/u3.json#/' eClass: '/model.json#//User'
Support for XMI has been added in version 0.3.0. This support requires sax.js.
var Ecore = ;var resourceSet = EcoreResourceSet;var resource = resourceSet;resource; // data being a string containing the XMI.resource; // returns the XMI string
If you want to contribute to this project or simply build from the source, you first need to clone the project by executing the following command in your terminal.
> git clone
Once these are installed, go back to your terminal and enter the ecore.js directory.
> cd ecore.js
The tests are written using the mocha library. To run them, execute the following command:
> grunt test
Running a build will create a new distribution in the folder dist. This is done by executing the command:
> grunt build
That's it, you are now ready to contribute to the project.
This software is distributed under the terms of the Eclipse Public License 1.0 - http://www.eclipse.org/legal/epl-v10.html.