Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Validating a model instance with the generated XSD Schema
Validating a model instance with the generated XSD Schema [message #945914] Mon, 15 October 2012 19:40 Go to next message
Phil Beauvoir is currently offline Phil Beauvoir
Messages: 22
Registered: October 2012
Junior Member
I use EMF to define an Ecore model, then generate the model code with the .genmodel file. In my application instances of the model are created using the generated Java code and saved as XML files.

I would like the user to be able validate those instances against an XSD Schema file. So I right-click on the .genmodel and choose "Export..." and follow the wizard to create the XSD file. However, within Eclipse, validation of the instance against this XSD fails. Looking at the XSD there are a lot of ECore: type constructs, could this be the reason?

[Updated on: Mon, 15 October 2012 21:26]

Report message to a moderator

Re: Validating a model instance with the generated XSD Schema [message #946240 is a reply to message #945914] Tue, 16 October 2012 03:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26152
Registered: July 2009
Senior Member
Phillipus,

Comments below.

On 15/10/2012 9:51 PM, Phillipus B wrote:
> I use EMF to define an Ecore model, then generate the model code with
> the .genmodel file. In my application instances of the model are
> created using the generated Java code and saved as XML files.
By default you get XMI serialization. Did you do something to alter that?
>
> I would like the user to be able validate those instances against an
> XSD Schema file. So I right-click on the .genmodel and choose
> "Export..." and follow the wizard to create the XSD file.
Did you pick the XMI or the XML option?
> However, within Eclipse validation of the instance against this XSD
> fails. Looking at the XSD there are a lot of ECore: type constructs,
> could this be the reason?
You'd want to make sure the XSD itself is valid (it should be) and that
references to Ecore.xsd resolve properly (I expect they should from the
location where the schema is generated).
Re: Validating a model instance with the generated XSD Schema [message #946886 is a reply to message #946240] Tue, 16 October 2012 15:49 Go to previous messageGo to next message
Phil Beauvoir is currently offline Phil Beauvoir
Messages: 22
Registered: October 2012
Junior Member
Thanks for replying, comments inline...


On 15/10/2012 9:51 PM, Phillipus B wrote:
> I use EMF to define an Ecore model, then generate the model code with
> the .genmodel file. In my application instances of the model are
> created using the generated Java code and saved as XML files.
By default you get XMI serialization. Did you do something to alter that?

I set it to generate XML so that the factory is a subclass of XMLResourceImpl. However, I have also tried it set to XMI for a XMIResourceImpl.



> I would like the user to be able validate those instances against an
> XSD Schema file. So I right-click on the .genmodel and choose
> "Export..." and follow the wizard to create the XSD file.
Did you pick the XMI or the XML option?

I've tried both. Initially the XML option, as I was creating XML instances but also XMI after I changed the setting in the genmodel to create XMI.



> However, within Eclipse validation of the instance against this XSD
> fails. Looking at the XSD there are a lot of ECore: type constructs,
> could this be the reason?
You'd want to make sure the XSD itself is valid (it should be) and that
references to Ecore.xsd resolve properly (I expect they should from the
location where the schema is generated).

Yes, this is fine, I added a Ecore.xsd file and the generated XSD validates.

With either XML or XMI I'm not getting validation. With everything set to generate XMI (instances and schema) I'm getting validation errors such as:

"Type 'archimate:AccessRelationship' is not validly derived from the type definition, 'EObject', of element 'element'."

And:

"Invalid content was found starting with element 'purpose'. One of '{folder, "hxxp://www.omg.org/XMI":Extension, property}' is expected."


My Ecore file uses annotations of ExtendedMetaData to change element names and set some attribute types to element types, would that affect it?

Re: Validating a model instance with the generated XSD Schema [message #946989 is a reply to message #946886] Tue, 16 October 2012 17:59 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26152
Registered: July 2009
Senior Member
Phillipus,

Comments below.

On 16/10/2012 5:49 PM, Phillipus B wrote:
> Thanks for replying, comments inline...
>
>
> On 15/10/2012 9:51 PM, Phillipus B wrote:
>> I use EMF to define an Ecore model, then generate the model code with
>> the .genmodel file. In my application instances of the model are
>> created using the generated Java code and saved as XML files.
> By default you get XMI serialization. Did you do something to alter
> that?
>
> I set it to generate XML so that the factory is a subclass of
> XMLResourceImpl. However, I have also tried it set to XMI for a
> XMIResourceImpl.
So which is it then?
>
>
>
>> I would like the user to be able validate those instances against an
>> XSD Schema file. So I right-click on the .genmodel and choose
>> "Export..." and follow the wizard to create the XSD file.
> Did you pick the XMI or the XML option?
>
> I've tried both. Initially the XML option, as I was creating XML
> instances but also XMI after I changed the setting in the genmodel to
> create XMI.
So did you use the appropriate schema for the appropriate type of instance?
>
>
>> However, within Eclipse validation of the instance against this XSD
>> fails. Looking at the XSD there are a lot of ECore: type constructs,
>> could this be the reason?
> You'd want to make sure the XSD itself is valid (it should be) and
> that references to Ecore.xsd resolve properly (I expect they should
> from the location where the schema is generated).
>
> Yes, this is fine, I added a Ecore.xsd file and the generated XSD
> validates.
>
> With either XML or XMI I'm not getting validation. With everything set
> to generate XMI (instances and schema) I'm getting validation errors
> such as:
>
> "Type 'archimate:AccessRelationship' is not validly derived from the
> type definition, 'EObject', of element 'element'."
Can you make a small example?
>
> And:
>
> "Invalid content was found starting with element 'purpose'. One of
> '{folder, "hxxp://www.omg.org/XMI":Extension, property}' is expected."
What did you do to end up with extension elements? Again, a simple
example would help make this concrete?
>
>
> My Ecore file uses annotations of ExtendedMetaData to change element
> names and set some attribute types to element types, would that affect
> it?
It's not clear what "this" is yet.

If you think there's a bug, create a small test case, i.e., a zipped
projects I can run locally that demonstrates what looks to be the problem.
>
>
Previous Topic:[CDO] really removing a DB record
Next Topic:[xcore] Obtaining the featureID in op
Goto Forum:
  


Current Time: Fri Oct 31 05:13:00 GMT 2014

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

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