Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XSDEcoreBuilder and ePackage.name
XSDEcoreBuilder and ePackage.name [message #415955] Sun, 13 January 2008 05:16 Go to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi,
I have a question about how the XSDEcoreBuilder sets the ePackage.name. My experience is that if
there is a targetNameSpace that the name of the EPackage is set to the java qualified package name.
When I look in the code (XSDEcoreBuilder.getEPackage) it indeed seems to work like this.

However when I do a new EMF model in Eclipse (when rightclicking on an xsd) I get a nicer epackage
name. So there seems to be different behavior.

Here is the top part of the xsd I am using:
<schema targetNamespace="http://www.elver.org/test/models/accounting"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:this="http://www.elver.org/test/models/accounting"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
ecore:name="accounting" ecore:nsPrefix="acc">

I would like the name accounting but the XSDEcoreBuilder gives me: org.elver.test.models.accounting.

I have tried to change the behavior by adding ecore:name but the ecore:name attribute is not used by
XSDEcoreBuilder for an ePackage.

Is there something which I am doing wrong? Or should I use another xsdtoecore builder (the one used
by the new emf model wizard)?

Thanks!

--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: XSDEcoreBuilder and ePackage.name [message #415958 is a reply to message #415955] Sun, 13 January 2008 12:44 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030206030209060007080302
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Martin,

It's always kind of bothered me this whole issue of names for root
packages. Of course we have a constraint that the name of an
ENamedElement must be well formed Java identifier and hence can't
contain a ".". But that means to specify a fully qualified package
name for generation purposes we either have to create a whole set of
parent EPackage for the sole purpose of specifying the qualifies. I.e.,
the Ecore package's name is "ecore" but we want to generate to
org.eclipse.emf.ecore. To achieve that, we use the GenPackage's Base
Package property. But of course this approach makes the information
about qualification not available to the EPackage itself. And even if
you did specify a bunch of parent EPackage's EMF wouldn't generate them
if they contain no classifiers, i.e., an EPackage containing only other
EPackages but no EClassifiers will not actually be generated:142856
<https://bugs.eclipse.org/bugs/show_bug.cgi?id=142856>

So what you're seeing in the XSDEcoreBuilder is kind of a
less-than-optimal solution where we populate the EPackage with the fully
qualified name (which you can explicitly set with an ecore:package
annotation) and then later when building the GenModel, we split that
name up and use it to populate the GenPackage's Base Package property.
Note that we did it this way because we don't want the XSD model to
depend on the GenModel and generally don't want the XSDEcoreBuilder,
which is used even for dynamic models, to depend on the GenModel, which
is more of a development time artifact.

So you can use ecore:package to shorten the name or you could specialize
the getEPackage method to shorten the name automatically. I've given
quite a bit of though to allowing the name of a package to contain a "."
or to introduce a qualifier attribute to EPackage itself, but all such
things are potentially disruptive to clients...


Martin Taal wrote:
> Hi,
> I have a question about how the XSDEcoreBuilder sets the
> ePackage.name. My experience is that if there is a targetNameSpace
> that the name of the EPackage is set to the java qualified package
> name. When I look in the code (XSDEcoreBuilder.getEPackage) it indeed
> seems to work like this.
>
> However when I do a new EMF model in Eclipse (when rightclicking on an
> xsd) I get a nicer epackage name. So there seems to be different
> behavior.
>
> Here is the top part of the xsd I am using:
> <schema
> targetNamespace="http://www.elver.org/test/models/accounting"
>
> xmlns="http://www.w3.org/2001/XMLSchema"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:this="http://www.elver.org/test/models/accounting"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> ecore:name="accounting" ecore:nsPrefix="acc">
>
> I would like the name accounting but the XSDEcoreBuilder gives me:
> org.elver.test.models.accounting.
>
> I have tried to change the behavior by adding ecore:name but the
> ecore:name attribute is not used by XSDEcoreBuilder for an ePackage.
>
> Is there something which I am doing wrong? Or should I use another
> xsdtoecore builder (the one used by the new emf model wizard)?
>
> Thanks!
>


--------------030206030209060007080302
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Martin,<br>
<br>
It's always kind of bothered me this whole issue of names for root
packages.&nbsp; Of course we have a constraint that the name of an
ENamedElement must be well formed Java identifier and hence can't
contain a&nbsp; ".".&nbsp; But that means to specify a fully qualified package
name for generation purposes we either have to create a whole set of
parent EPackage for the sole purpose of specifying the qualifies.&nbsp;
I.e., the Ecore package's name is "ecore" but we want to generate to
org.eclipse.emf.ecore.&nbsp; To achieve that, we use the GenPackage's Base
Package property.&nbsp; But of course this approach makes the information
about qualification not available to the EPackage itself.&nbsp; And even if
you did specify a bunch of parent EPackage's EMF wouldn't generate them
if they contain no classifiers, i.e., an EPackage containing only other
EPackages but no EClassifiers will not actually be generated:<a
name="b142856"
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=142856">142856</a><br>
<br>
So what you're seeing in the XSDEcoreBuilder is kind of a
less-than-optimal solution where we populate the EPackage with the
fully qualified name (which you can explicitly set with an
ecore:package annotation) and then later when building the GenModel, we
split that name up and use it to populate the GenPackage's Base Package
property.&nbsp; Note that we did it this way because we don't want the XSD
model to depend on the GenModel and generally don't want the
XSDEcoreBuilder, which is used even for dynamic models, to depend on
the GenModel, which is more of a development time artifact.<br>
<br>
So you can use ecore:package to shorten the name or you could
specialize the getEPackage method to shorten the name automatically.&nbsp;
I've given quite a bit of though to allowing the name of a package to
contain a "." or to introduce a qualifier attribute to EPackage itself,
but all such things are potentially disruptive to clients...<br>
<br>
<br>
Martin Taal wrote:
<blockquote cite="mid:fmc6s3$3pq$1@build.eclipse.org" type="cite">Hi,
<br>
I have a question about how the XSDEcoreBuilder sets the ePackage.name.
My experience is that if there is a targetNameSpace that the name of
the EPackage is set to the java qualified package name. When I look in
the code (XSDEcoreBuilder.getEPackage) it indeed seems to work like
this.
<br>
<br>
However when I do a new EMF model in Eclipse (when rightclicking on an
xsd) I get a nicer epackage name. So there seems to be different
behavior.
<br>
<br>
Here is the top part of the xsd I am using:
<br>
&lt;schema
targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://www.elver.org/test/models/accounting">"http://www.elver.org/test/models/accounting"</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;xmlns:ecore=<a class="moz-txt-link-rfc2396E" href="http://www.eclipse.org/emf/2002/Ecore">"http://www.eclipse.org/emf/2002/Ecore"</a>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;xmlns:this=<a class="moz-txt-link-rfc2396E" href="http://www.elver.org/test/models/accounting">"http://www.elver.org/test/models/accounting"</a>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;xmlns:xsd=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;ecore:name="accounting " ecore:nsPrefix="acc"&gt;
<br>
<br>
I would like the name accounting but the XSDEcoreBuilder gives me:
org.elver.test.models.accounting.
<br>
<br>
I have tried to change the behavior by adding ecore:name but the
ecore:name attribute is not used by XSDEcoreBuilder for an ePackage.
<br>
<br>
Is there something which I am doing wrong? Or should I use another
xsdtoecore builder (the one used by the new emf model wizard)?
<br>
<br>
Thanks!
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------030206030209060007080302--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Exctract eType from within eStructuralFeature using JET
Next Topic:Eclipse Forms, IItemPropertyDescriptor and EList
Goto Forum:
  


Current Time: Thu Apr 25 05:58:18 GMT 2024

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

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

Back to the top