Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » What is the recommended way of joining multiple XSDs in a single ECore model?
What is the recommended way of joining multiple XSDs in a single ECore model? [message #865447] Mon, 30 April 2012 12:03 Go to next message
Seref Arikan is currently offline Seref ArikanFriend
Messages: 73
Registered: August 2010
Member
I am using a set of XSDs that represent domain models for openEHR electronic health record standard. The schemas are modelled so that various schemas are shared by others.
A convenient feature of JAXB is that you can give a directory to jaxb code generator as input, and it would give you all types in all XSDs under that directory. This is especially useful to build a single Java package that will be used for xml data binding.
I could not find a convenient way of doing the same with XSD to ECore conversion. If I point towards a single XSD from the XSD set I'm using, the result is an ECore model that does not include some of the types in XSDs which are not referenced from the pointed XSD.
I end up with creating ECore models from each XSD in the directory, and then I choose one ECore model and load resource(s) to include other models.
Is this the right way to end up with the full ECore model for the whole of XSDs? Is there any other way that would give me a single ECore model from multiple XSDs? Is there anything that may be a problem in my current approach?

Re: What is the recommended way of joining multiple XSDs in a single ECore model? [message #865555 is a reply to message #865447] Mon, 30 April 2012 13:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Seref,

Comments below.

On 30/04/2012 2:03 PM, Seref Arikan wrote:
> I am using a set of XSDs that represent domain models for openEHR
> electronic health record standard. The schemas are modelled so that
> various schemas are shared by others. A convenient feature of JAXB is
> that you can give a directory to jaxb code generator as input, and it
> would give you all types in all XSDs under that directory. This is
> especially useful to build a single Java package that will be used for
> xml data binding. I could not find a convenient way of doing the same
> with XSD to ECore conversion. If I point towards a single XSD from the
> XSD set I'm using, the result is an ECore model that does not include
> some of the types in XSDs which are not referenced from the pointed XSD.
You can convert several schemas at once. I.e., the wizard lets you
provide a space separated list of URIs for the schemas...
> I end up with creating ECore models from each XSD in the directory,
> and then I choose one ECore model and load resource(s) to include
> other models. Is this the right way to end up with the full ECore
> model for the whole of XSDs?
You'll always end up with a separate EPackage per XML Schema
targetNamespace. If you have a bunch of schemas all with the same
namespace, you should list them all in the wizard when doing the conversion.
> Is there any other way that would give me a single ECore model from
> multiple XSDs?
If they have different targetNamespaces, you can't combine them, if they
all share a targetNamespace, then you can...
> Is there anything that may be a problem in my current approach?
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: What is the recommended way of joining multiple XSDs in a single ECore model? [message #867614 is a reply to message #865555] Tue, 01 May 2012 11:39 Go to previous messageGo to next message
Seref Arikan is currently offline Seref ArikanFriend
Messages: 73
Registered: August 2010
Member
Thanks Ed,
For some reason I've failed to do this before; I was getting an error (probably a problem that existed in a previuos version of the XSDs).
I've tried it again and I can confirm that I've ended up with a single ECore, which is quite convenient. Especially having a single DocumentRoot that contains all possible root elements is something I probably would not have easily if I were to join multiple XSDs. (actually this is worth checking out. Multiple XSDs, sharing same namespace, processed into their own ECores. What if I load an ecore as resource into another: what happens to DocumentRoot(s) from two different ECores?. Hmm...)

Kind regards
Seref


Re: What is the recommended way of joining multiple XSDs in a single ECore model? [message #867901 is a reply to message #867614] Tue, 01 May 2012 14:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Seref,

Comments below.

On 01/05/2012 1:39 PM, Seref Arikan wrote:
> Thanks Ed, For some reason I've failed to do this before; I was
> getting an error (probably a problem that existed in a previuos
> version of the XSDs). I've tried it again and I can confirm that I've
> ended up with a single ECore, which is quite convenient. Especially
> having a single DocumentRoot that contains all possible root elements
> is something I probably would not have easily if I were to join
> multiple XSDs. (actually this is worth checking out. Multiple XSDs,
> sharing same namespace, processed into their own ECores. What if I
> load an ecore as resource into another: what happens to
> DocumentRoot(s) from two different ECores?. Hmm...)
*.ecore resources have an EPackage at the root, so you'd gain nothing by
putting them in the same resource.
>
> Kind regards
> Seref
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: What is the recommended way of joining multiple XSDs in a single ECore model? [message #868337 is a reply to message #867901] Tue, 01 May 2012 19:17 Go to previous messageGo to next message
Seref Arikan is currently offline Seref ArikanFriend
Messages: 73
Registered: August 2010
Member
Hi Ed,
Actually, I was curious about it, what would happen if I load another resource, with some types overlapping (due to underlying XSD sources) and create references to second resource from the first one?

The genmodel gave me an error about root packages having the same namespace. So it did not (correctly) let me move forward Smile

Thanks for your help, again.

Best regards
Seref


Re: What is the recommended way of joining multiple XSDs in a single ECore model? [message #868510 is a reply to message #868337] Wed, 02 May 2012 05:50 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Seref,

Yes, an EPackage must be uniquely identifiable via its nsURI.

On 01/05/2012 9:17 PM, Seref Arikan wrote:
> Hi Ed, Actually, I was curious about it, what would happen if I load
> another resource, with some types overlapping (due to underlying XSD
> sources) and create references to second resource from the first one?
> The genmodel gave me an error about root packages having the same
> namespace. So it did not (correctly) let me move forward :)
>
> Thanks for your help, again.
>
> Best regards
> Seref
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[cdo] Options for searching the CDO store
Next Topic:Cannot find eProxyURI: platform:/plugin/org.eclipse.xsd/model/XSD.ecore#//XSDSchema
Goto Forum:
  


Current Time: Tue Apr 23 14:01:23 GMT 2024

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

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

Back to the top