Ecore validation [message #1219438] |
Tue, 03 December 2013 15:57  |
Eclipse User |
|
|
|
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 #1219503 is a reply to message #1219478] |
Wed, 04 December 2013 05:20   |
Eclipse User |
|
|
|
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
|
|
|
|
Re: Ecore validation [message #1808099 is a reply to message #1808093] |
Mon, 17 June 2019 09:00  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.50951 seconds