Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to make EMF use extendedMetaData
How to make EMF use extendedMetaData [message #423229] Thu, 25 September 2008 10:28 Go to next message
ronald Mising name is currently offline ronald Mising nameFriend
Messages: 52
Registered: July 2009
Member
Hi all,

Short Question: Which property do I have to set to use metadata?
I've set the Suppress EMF Metadata property to false in the genmodel,
but the XYZResourceFactoryImpl doesn't initialize the extendedMetaData
when I regenerate the model.

Explanation:
I've got two models, of which one (ABC) is using the extendedMetaData.
When I generate that last one, I get code in the ABCResourceFactoryImpl
like:

protected ExtendedMetaData extendedMetaData;

public ModelResourceFactoryImpl() {
super();
extendedMetaData = new BasicExtendedMetaData(new
EPackageRegistryImpl(EPackage.Registry.INSTANCE));
extendedMetaData.putPackage(null, ModelPackage.eINSTANCE);
}

public Resource createResource(URI uri) {
XMLResource result = new ModelResourceImpl(uri);
result.getDefaultSaveOptions().put(
XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
result.getDefaultLoadOptions().put(
XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
...
}

In the other model (XYZ), this code is not generated and in its
createResource method, this code is generated:

result.getDefaultSaveOptions().put(
XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);

I've looked at the genmodel of both models, and in both models, the
Suppress EMF Metadata is set to false...
Why is code generated for model XYZ not using extendedMetaData? Which
property do I have to set to use metadata?


TIA
Ronaldo
Re: How to make EMF use extendedMetaData [message #423235 is a reply to message #423229] Thu, 25 September 2008 10:50 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31494
Registered: July 2009
Senior Member
Ronaldo,

Comments below.

Ronaldo wrote:
> Hi all,
>
> Short Question: Which property do I have to set to use metadata?
That's an overloaded question...
> I've set the Suppress EMF Metadata property to false in the genmodel,
> but the XYZResourceFactoryImpl doesn't initialize the extendedMetaData
> when I regenerate the model.
That's unrelated. That suppresses the generation of @model annotations
in the generated Javadoc.
>
> Explanation:
> I've got two models, of which one (ABC) is using the extendedMetaData.
> When I generate that last one, I get code in the
> ABCResourceFactoryImpl like:
>
> protected ExtendedMetaData extendedMetaData;
>
> public ModelResourceFactoryImpl() {
> super();
> extendedMetaData = new BasicExtendedMetaData(new
> EPackageRegistryImpl(EPackage.Registry.INSTANCE));
> extendedMetaData.putPackage(null, ModelPackage.eINSTANCE);
I'd expect this for a model corresponding to a null targetNamespace schema.
> }
>
> public Resource createResource(URI uri) {
> XMLResource result = new ModelResourceImpl(uri);
> result.getDefaultSaveOptions().put(
> XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
> result.getDefaultLoadOptions().put(
> XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
> ...
> }
>
> In the other model (XYZ), this code is not generated and in its
> createResource method, this code is generated:
>
> result.getDefaultSaveOptions().put(
> XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
That I'd expect for a schema with a targetNamespace.
>
> I've looked at the genmodel of both models, and in both models, the
> Suppress EMF Metadata is set to false...
> Why is code generated for model XYZ not using extendedMetaData? Which
> property do I have to set to use metadata?
They both use extended metadata, but the null targetNamespace thing is
tricky because the nsURI of the EPackage must uniquely identify it and
hence we can't support many packages all with null nsURI. So the
package corresponding to a null targetNamespace schema is assigned an
nsURI and then needs special handling so that it's treated as it the
nsURI were null...
>
>
> TIA
> Ronaldo


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to make EMF use extendedMetaData [message #423236 is a reply to message #423235] Thu, 25 September 2008 11:17 Go to previous messageGo to next message
ronald Mising name is currently offline ronald Mising nameFriend
Messages: 52
Registered: July 2009
Member
Hi Ed,

Thanks for the quick answer. Yes, I have 2 models in 2 different eclipse
projects.
They both use a null target namespace, in order to eliminate the
prefixes in the xml.

I was just wondering what (which setting) causes the code

result.getDefaultSaveOptions().put(
XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);

to be generated. (as opposed to

result.getDefaultSaveOptions().put(
XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
)

Ronaldo

Ed Merks wrote:
> Ronaldo,
>
> Comments below.
>
> Ronaldo wrote:
>> Hi all,
>>
>> Short Question: Which property do I have to set to use metadata?
> That's an overloaded question...
>> I've set the Suppress EMF Metadata property to false in the genmodel,
>> but the XYZResourceFactoryImpl doesn't initialize the extendedMetaData
>> when I regenerate the model.
> That's unrelated. That suppresses the generation of @model annotations
> in the generated Javadoc.
>>
>> Explanation:
>> I've got two models, of which one (ABC) is using the extendedMetaData.
>> When I generate that last one, I get code in the
>> ABCResourceFactoryImpl like:
>>
>> protected ExtendedMetaData extendedMetaData;
>>
>> public ModelResourceFactoryImpl() {
>> super();
>> extendedMetaData = new BasicExtendedMetaData(new
>> EPackageRegistryImpl(EPackage.Registry.INSTANCE));
>> extendedMetaData.putPackage(null, ModelPackage.eINSTANCE);
> I'd expect this for a model corresponding to a null targetNamespace schema.
>> }
>>
>> public Resource createResource(URI uri) {
>> XMLResource result = new ModelResourceImpl(uri);
>> result.getDefaultSaveOptions().put(
>> XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
>> result.getDefaultLoadOptions().put(
>> XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
>> ...
>> }
>>
>> In the other model (XYZ), this code is not generated and in its
>> createResource method, this code is generated:
>>
>> result.getDefaultSaveOptions().put(
>> XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
> That I'd expect for a schema with a targetNamespace.
>>
>> I've looked at the genmodel of both models, and in both models, the
>> Suppress EMF Metadata is set to false...
>> Why is code generated for model XYZ not using extendedMetaData? Which
>> property do I have to set to use metadata?
> They both use extended metadata, but the null targetNamespace thing is
> tricky because the nsURI of the EPackage must uniquely identify it and
> hence we can't support many packages all with null nsURI. So the
> package corresponding to a null targetNamespace schema is assigned an
> nsURI and then needs special handling so that it's treated as it the
> nsURI were null...
>>
>>
>> TIA
>> Ronaldo
Re: How to make EMF use extendedMetaData [message #423238 is a reply to message #423236] Thu, 25 September 2008 11:28 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31494
Registered: July 2009
Senior Member
Ronaldo,

Comments below.

Ronaldo wrote:
> Hi Ed,
>
> Thanks for the quick answer. Yes, I have 2 models in 2 different
> eclipse projects.
> They both use a null target namespace, in order to eliminate the
> prefixes in the xml.
:-(

XML documents with at least a namespace for the root element are
generally more consumable because they identify their schema...
>
> I was just wondering what (which setting) causes the code
>
> result.getDefaultSaveOptions().put(
> XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
A null target namespace schema produces an annotation on the EPackage to
indicate the package is not qualified.
>
> to be generated. (as opposed to
>
> result.getDefaultSaveOptions().put(
> XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
This package doesn't have such an annotation.

Note that you can't have two different packages that both want to be the
one for the null namespace both working at the same time.
> )
>
> Ronaldo
>
> Ed Merks wrote:
>> Ronaldo,
>>
>> Comments below.
>>
>> Ronaldo wrote:
>>> Hi all,
>>>
>>> Short Question: Which property do I have to set to use metadata?
>> That's an overloaded question...
>>> I've set the Suppress EMF Metadata property to false in the genmodel,
>>> but the XYZResourceFactoryImpl doesn't initialize the
>>> extendedMetaData when I regenerate the model.
>> That's unrelated. That suppresses the generation of @model
>> annotations in the generated Javadoc.
>>>
>>> Explanation:
>>> I've got two models, of which one (ABC) is using the
>>> extendedMetaData. When I generate that last one, I get code in the
>>> ABCResourceFactoryImpl like:
>>>
>>> protected ExtendedMetaData extendedMetaData;
>>>
>>> public ModelResourceFactoryImpl() {
>>> super();
>>> extendedMetaData = new BasicExtendedMetaData(new
>>> EPackageRegistryImpl(EPackage.Registry.INSTANCE));
>>> extendedMetaData.putPackage(null, ModelPackage.eINSTANCE);
>> I'd expect this for a model corresponding to a null targetNamespace
>> schema.
>>> }
>>>
>>> public Resource createResource(URI uri) {
>>> XMLResource result = new ModelResourceImpl(uri);
>>> result.getDefaultSaveOptions().put(
>>> XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
>>> result.getDefaultLoadOptions().put(
>>> XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);
>>> ...
>>> }
>>>
>>> In the other model (XYZ), this code is not generated and in its
>>> createResource method, this code is generated:
>>>
>>> result.getDefaultSaveOptions().put(
>>> XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
>> That I'd expect for a schema with a targetNamespace.
>>>
>>> I've looked at the genmodel of both models, and in both models, the
>>> Suppress EMF Metadata is set to false...
>>> Why is code generated for model XYZ not using extendedMetaData?
>>> Which property do I have to set to use metadata?
>> They both use extended metadata, but the null targetNamespace thing
>> is tricky because the nsURI of the EPackage must uniquely identify it
>> and hence we can't support many packages all with null nsURI. So the
>> package corresponding to a null targetNamespace schema is assigned an
>> nsURI and then needs special handling so that it's treated as it the
>> nsURI were null...
>>>
>>>
>>> TIA
>>> Ronaldo


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:CreateChildCommand and EStore
Next Topic:Re: Has anyone experienced something like this?
Goto Forum:
  


Current Time: Wed Sep 30 22:36:13 GMT 2020

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

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

Back to the top