Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Ecore validation
Ecore validation [message #1219438] Tue, 03 December 2013 20:57 Go to next message
Tyler Lee is currently offline Tyler LeeFriend
Messages: 4
Registered: December 2013
Junior Member
Dear Members,

How does EMF provide an interface to parse and validate the XMI (e.g. UML2) models? Is the validation done against the corresponding .ecore file as a metamodel?

Taking a look at the UML2 Eclipse package I have noticed that there were Java files generated for the metamodel however there is not schema (.xsd) available for UML2. How do these files (e.g. BehavioredClassifier.java which is one of the elements of UML2) get generated? Is validation based upon these Java files?

My purpose is to make a plugin which calls certain methods of EMF to validate my projects. I just do not know which packages, classes and methods I shall take into consideration.

Many thanks,
Tyler
Re: Ecore validation [message #1219475 is a reply to message #1219438] Wed, 04 December 2013 05:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Tyler,

Comments below.

On 03/12/2013 9:57 PM, Tyler Lee wrote:
> Dear Members,
>
> How does EMF provide an interface to parse and validate the XMI (e.g.
> UML2) models? Is the validation done against the corresponding .ecore
> file as a metamodel?
No,the UML2 project provides that.
>
> Taking a look at the UML2 Eclipse package I have noticed that there
> were Java files generated for the metamodel however there is not
> schema (.xsd) available for UML2.
XML Schema can't represent multiple inheritance and I"m pretty sure UML2
relies on that, and in any case, XMI has a very loose syntax whose
syntax can't be well validated via an XML Schema.
> How do these files (e.g. BehavioredClassifier.java which is one of the
> elements of UML2) get generated?
Follow one of EMF's introductory tutorials.
> Is validation based upon these Java files?
They're used to represent the result of parsing the XMI.
>
> My purpose is to make a plugin which calls certain methods of EMF to
> validate my projects. I just do not know which packages, classes and
> methods I shall take into consideration.
You'll want to use UML2 do look at that project's introductory
tutorials. Questions about UML2 should be directed to the
eclipse.modeling.mdt.uml2 forum/newsgroup.
>
> Many thanks,
> Tyler


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ecore validation [message #1219478 is a reply to message #1219475] Wed, 04 December 2013 06:05 Go to previous messageGo to next message
Tyler Lee is currently offline Tyler LeeFriend
Messages: 4
Registered: December 2013
Junior Member
Dear Ed,

Thank you for the clarification. In terms of the introductory tutorials first of all I need to generate Java code from .uml or its .ecore representation. Once it is done using EMF I can validate my XMI model resource against the event-based SAX parser along with these marshaled Java objects. In other words validation errors are produced as the resource is loaded (trying to build the object hierarchy). That is why if I have a nested UML class error for example, it will only come to see if I browse the nesting class in the UML/EMF/GMF editor (the active elements of the resource are checked).

Is it the general approach what Eclipse uses for validating XML resources then? Please correct me if I am mistaken in any regards.

Regards,
Tyler
Re: Ecore validation [message #1219503 is a reply to message #1219478] Wed, 04 December 2013 10:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Tyler,

Comments below.

On 04/12/2013 7:05 AM, Tyler Lee wrote:
> Dear Ed,
>
> Thank you for the clarification. In terms of the introductory
> tutorials first of all I need to generate Java code from .uml or its
> .ecore representation.
It's not clear what you're doing. UML2 is already generated so perhaps
you just need to use that.
> Once it is done using EMF I can validate my XMI model resource against
> the event-based SAX parser along with these marshaled Java objects.
EMF can parse any XMI given you have an Ecore model for it, e.g.,
UML2.ecore is used to parse UML2...
> In other words validation errors are produced as the resource is
> loaded (trying to build the object hierarchy).
Yes, if the instance is wrong, errors will be diagnosed.
> That is why if I have a nested UML class error
What's that?
> for example, it will only come to see if I browse the nesting class in
> the UML/EMF/GMF editor (the active elements of the resource are checked).
The resource throws exceptions if the syntax is invalid. Many editors
catch this exception and show what's possible to parse. Many models also
add constraints on top of just the XMI parsing, e.g., in Ecore it's
invalid for more than one classifier in a package to have the same name...
>
> Is it the general approach what Eclipse uses for validating XML
> resources then?
You've switched from XMI to XML now. Validating XML in general can be
done with an XML schema. EMF can be used as an XML binding framework,
similar to JAXB.
> Please correct me if I am mistaken in any regards.
>
> Regards,
> Tyler


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Ecore validation [message #1808093 is a reply to message #1219438] Mon, 17 June 2019 11:31 Go to previous messageGo to next message
Ilja Shmelkin is currently offline Ilja ShmelkinFriend
Messages: 5
Registered: May 2019
Junior Member
Hello,

I came across a similar problem. Unfortunately I cant really find a thread which describes the validation of ecore and ecore based models.

I have to show that my designed models can be validated. Im pretty sure that EMF does that for free - nevertheless I have to undestand how exactly ecore is validated against its own description and how my selfmade ecore-model is validated against ecore.
To be more precise:
What mechanisms are providing the validation (I found something about constraints, but not really how they are defined, https://www.informatik.hu-berlin.de/de/forschung/gebiete/ti/sam/Lehre/modellbasierte-softwareentwicklung-modsoft/vorlesung/DSLs/v6-modsoft-ii.-validation.pdf)?
Which engine parses the XMI?
Which engine drops errors when finding invalid XMI?
How could I, if its possible at all, use the same mechanism in my own webapplication (for example, I found https://stackoverflow.com/questions/3667867/run-emf-validation-of-an-ecore-model-outside-of-eclipse)?



Thank you,
Ilja

[Updated on: Mon, 17 June 2019 11:40]

Report message to a moderator

Re: Ecore validation [message #1808099 is a reply to message #1808093] Mon, 17 June 2019 13:00 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

EMF Validation occurs whenever an application uses typically a Diagnostician to activate the generated or reflective EValidator.

Traditionally this occurred when the "Validate" menu entry was invoked within an EMF-based application such as an Ecore Editor.

Quite a few years ago now, Live Validation was added so that within those applications validation can happen automatically.

The "Validate" action can be applied to just some selected objects, which can be a bit confusing since the Problem View shows the results of the most recent "Validate" action.

Within Eclipse many tools such as JDT automatically update the Problems View to show the prevailing state of the art using a Builder. EMF has no Builder so there is no automatic update of the Problem View for EMF models.

The OCL project, which supports OCL embedded within Ecore (OCLinEcore), provides a builder and nature for OCLinEcore and can be configured to also provide a builder for *.ecore and *.uml and ... giving the normal Eclipse behaviour; the problems with bad models can be automatically shown in the Problems View.

The EValidator checks constraints, many of which such as lowerbound <= upperbound are hard coded in EMF's Java. You can write your own Java for your models. You can use Java-like Xbase to define constraints using Xcore. You can have Java autogenerated from OCL if you use OCLinEcore. Historically the EMFv project provided an XML embedding of constraints, but this has long since been superseded.

https://wiki.eclipse.org/OCL/OCLinEcore provides some clues as to how constraints may be added to an Ecore model.

Regards

Ed Willink

Within Eclipse
Previous Topic:Over-riding EContentAdapter#addAdapter - side effects?
Next Topic:Dynamic loading of Meta Model
Goto Forum:
  


Current Time: Thu Apr 25 05:39:33 GMT 2024

Powered by FUDForum. Page generated in 0.04498 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top