Logo

4.1 Importing and exporting with MSE

The preferred way to load a model in Moose is via an MSE file. To load an MSE file, all you have to do is to press the “Import from MSE” button in the Moose Panel and indicate the file to load. This creates a model, populates it with the entities from the file and adds the model to the repository. Visually, the model appears in the list of models from the Moose Panel.

But what exactly is MSE? MSE is the default file format supported by Moose. It is a generic file format and can describe any model. It is similar to XML, the main difference being that instead of using verbose tags, it makes use of parentheses to denote the beginning and ending of an element.

The following snippet provides an example of a small model:

( (FAMIX.Namespace (id: 1)
    (name 'aNamespace'))
  (FAMIX.Package (id: 201)
    (name 'aPackage'))
  (FAMIX.Package (id: 202)
    (name 'anotherPackage')
    (parentPackage (ref: 201)))
  (FAMIX.Class (id: 2)
    (name 'ClassA')
    (container (ref: 1))
    (parentPackage (ref: 201)))
  (FAMIX.Method
    (name 'methodA1')
    (signature 'methodA1()')
    (parentType (ref: 2))
    (LOC 2))
  (FAMIX.Attribute 
    (name 'attributeA1')
    (parentType (ref: 2)))
  (FAMIX.Class (id: 3)
    (name 'ClassB')
    (container (ref: 1))
    (parentPackage (ref: 202)))
  (FAMIX.Inheritance
    (subclass (ref: 3))
    (superclass (ref: 2))))

The file defines 8 entities: 1 Namespace, 2 Packages, 2 Classes, 1 Method, 1 Attribute and 1 Inheritance. For each of these entities it provides a unique identifier (e.g., (id: 1)) and it defines properties. In general, properties can be either primitive, like (name ’aNamespace’), or they can point to another entity, like in the case of (container (ref: 1)) which denotes that the container property of ClassA points to the instance of Namespace named aNamespace.

The overall object graph can be seen graphically below.

The object graph from the sample MSE file

A more complex MSE example is available for download as described in Chapter 3.

Once a model is loaded, it can be easily exported as an MSE file. This can be done via the contextual menu of the model. By choosing the “Export to MSE” menu item you will be prompted to indicate the desired file name and location, and the result is an MSE file saved on the disk containing the entities in the model.

User Contributed Notes

tudor (3 April 2013, 9:30 am)

Thanks for the suggestion. We had XML, and did not scale at all. Now we have MSE.

alan.mcnamara (1 April 2013, 5:59 am)

Suggestion - upgrade MSE to XML. XML may be verbose, but has a great set of third party tools to support it.

tudor (11 October 2010, 4:18 am)

Thanks.

enrico.spinielli (10 October 2010, 3:27 pm)

A whitespace is needed before Import from MSE.

tudor (7 October 2010, 12:55 pm)

Thanks. I took them into account.

bginsbg (6 October 2010, 12:01 pm)

Typos (text to add enclosed by asterisks):

 

This creates a model, populate*s* it with the entities from the file and add*s* the model to the repository.

 

which denotes that the container of ClassA is aNamespace.

which denotes that the container of ClassA is a* *Namespace.

Add a Note