Home » Modeling » EMF » EObject to String
| | | | |
Re: EObject to String [message #507290 is a reply to message #507275] |
Tue, 12 January 2010 18:18 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Milan,
Well, a String can't be an EObject so that's just not going to work
other than how I've already spelled out. You could make the type be
EJavaObject, i.e., the EDataType that wraps java.lang.Object, but that's
not going to serialize nicely.
Milan Milanovich wrote:
> Dear Mr. Merks,
>
> well, my class is defined like this:
>
> class Expr {
> name : String;
> body : EObject;
> }
>
> i.e., body is EObject type, because I need to give it different
> reference types during runtime. Sometimes it should be instances of a
> String, but sometimes it should be EBoolean. I'm just wondering how to
> assign different types to the body in runtime.
>
> --
> Regards, Milan
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: EObject to String [message #508233 is a reply to message #507290] |
Sun, 17 January 2010 23:34 |
Milan Milanovich Messages: 201 Registered: July 2009 |
Senior Member |
|
|
Dear Mr. Merks,
I have created a volatile, transient property in my EMF code and tried to implement it, like this:
final CommonFactory factory = CommonFactoryImpl.eINSTANCE;
final CommonPackage cPackage = CommonPackageImpl.eINSTANCE;
ItemDefinition itemDefintion = factory.createItemDefinition();
SimpleAnyType ant = XMLTypeFactory.eINSTANCE.createSimpleAnyType();
ant.setInstanceType((EcorePackage.eINSTANCE.getEString()));
FormalExpression fe = factory.createFormalExpression();
fe.setBody(ant);
...
and on the end of this method, I call generated method to populate it with created data: setConditionExpression(fe);
However, when I try to save this object...graphically in GMF, I'm getting an error: ItemDefinition is not contained in a resource. What do I need to do?
--
Milan
[Updated on: Sun, 17 January 2010 23:36] Report message to a moderator
|
|
| |
Re: EObject to String [message #508349 is a reply to message #508237] |
Mon, 18 January 2010 14:09 |
Milan Milanovich Messages: 201 Registered: July 2009 |
Senior Member |
|
|
Dear Mr. Merks,
Ed Merks wrote on Sun, 17 January 2010 19:22 | Milan,
Comments below.
Milan Milanovich wrote:
> Dear Mr. Merks,
>
> I have created a volatile, transient property in my EMF code and tried
> to implement it, like this:
>
> final CommonFactory factory = CommonFactoryImpl.eINSTANCE;
Why access it via the Impl class when it's defined in the interface?
|
Yes, you are right, my mistake...
Ed Merks wrote on Sun, 17 January 2010 19:22 |
> final CommonPackage cPackage = CommonPackageImpl.eINSTANCE;
>
> ItemDefinition itemDefintion = factory.createItemDefinition();
>
> SimpleAnyType ant = XMLTypeFactory.eINSTANCE
> .createSimpleAnyType();
>
> ant.setInstanceType((EcorePackage.eINSTANCE.getEString()));
EcorePackage.Literals.ESTRING works too and it's a constant.
|
O.K.
Ed Merks wrote on Sun, 17 January 2010 19:22 |
> and on the end of this method, I call generated method to populate it
> with created data: setConditionExpression(fe);
>
> However, when I try to save this object...graphically in GMF, I'm
> getting an error: ItemDefinition is not contained in a resource. What
> do I need to do?
If it's a non-containment reference, you'll have to store it in some
other containment reference or at the root of a resource.
|
Yes, it is a non-containment reference, and I cannot store it to some other containment reference. So, I need to store it at the root of a resource ? How can I get a resource in my model Implementation class ?
--
thanks, Milan
|
|
|
Re: EObject to String [message #508386 is a reply to message #508349] |
Mon, 18 January 2010 15:54 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Milan,
In general you can't assume there is always a resource, but
EObject.eResource() will return it if there is one.
Milan Milanovich wrote:
> Dear Mr. Merks,
>
> Ed Merks wrote on Sun, 17 January 2010 19:22
>> Milan,
>>
>> Comments below.
>>
>> Milan Milanovich wrote:
>> > Dear Mr. Merks,
>> >
>> > I have created a volatile, transient property in my EMF code and
>> tried > to implement it, like this:
>> >
>> > final CommonFactory factory = CommonFactoryImpl.eINSTANCE;
>> Why access it via the Impl class when it's defined in the interface?
>
> Yes, you are right, my mistake...
>
> Ed Merks wrote on Sun, 17 January 2010 19:22
>> > final CommonPackage cPackage = CommonPackageImpl.eINSTANCE;
>> >
>> > ItemDefinition itemDefintion = factory.createItemDefinition();
>> >
>> > SimpleAnyType ant = XMLTypeFactory.eINSTANCE
>> > .createSimpleAnyType();
>> > >
>> ant.setInstanceType((EcorePackage.eINSTANCE.getEString()));
>> EcorePackage.Literals.ESTRING works too and it's a constant.
>
> O.K.
>
> Ed Merks wrote on Sun, 17 January 2010 19:22
>> > and on the end of this method, I call generated method to populate
>> it > with created data: setConditionExpression(fe);
>> >
>> > However, when I try to save this object...graphically in GMF, I'm >
>> getting an error: ItemDefinition is not contained in a resource. What
>> > do I need to do?
>> If it's a non-containment reference, you'll have to store it in some
>> other containment reference or at the root of a resource.
>
>
> Yes, it is a non-containment reference, and I cannot store it to some
> other containment reference. So, I need to store it at the root of a
> resource ? How can I get a resource in my model Implementation class ?
>
> --
> thanks, Milan
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | |
Re: EObject to String [message #508436 is a reply to message #508425] |
Mon, 18 January 2010 19:27 |
Milan Milanovich Messages: 201 Registered: July 2009 |
Senior Member |
|
|
Dear Mr. Merks,
Ed Merks wrote on Mon, 18 January 2010 12:56 | Milan,
resource.getContents().add(child)
|
Good, now I don't get the error, however all of these elements are not saved in the file. E.g., this is saved:
<conditionExpression xsi:type="bpmn2_2:FormalExpression" language="ocl" evaluatesToTypeRef="/1" body="/2"/>
evaluatesToTypeRef and body elements are the elements which I have added to the resource, but they are not saved in the file?
--
thanks, Milan
[Updated on: Mon, 18 January 2010 19:28] Report message to a moderator
|
|
|
Re: EObject to String [message #508588 is a reply to message #508436] |
Tue, 19 January 2010 14:48 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Milan,
Only an XMIResourceImpl will save multiple roots, so you'll need to rely
on an XMI serialization.
Milan Milanovich wrote:
> Dear Mr. Merks,
>
> Ed Merks wrote on Mon, 18 January 2010 12:56
>> Milan,
>>
>> resource.getContents().add(child)
>
>
> Good, now I don't get the error, however all of these elements are not
> saved in the file. E.g., this is saved:
>
> <conditionExpression xsi:type="bpmn2_2:FormalExpression"
> language="ocl" evaluatesToTypeRef="/1" body="/2"/>
>
> evaluatesToTypeRef and body elements are the elements which I have
> added to the resource, but they are not saved in the file?
>
> --
> thanks, Milan
>
> Ed Merks wrote on Mon, 18 January 2010 12:56
>> Milan Milanovich wrote:
>> > Dear Mr. Merks,
>> >
>> > Ed Merks wrote on Mon, 18 January 2010 10:54
>> >> Milan,
>> >>
>> >> In general you can't assume there is always a resource, but >>
>> EObject.eResource() will return it if there is one.
>> >
>> >
>> > O.K. Thank you.
>> >
>> > In the case, when I do this:
>> >
>> > final CommonFactory factory = CommonFactory.eINSTANCE;
>> > final CommonPackage cPackage = CommonPackage.eINSTANCE;
>> >
>> > ItemDefinition itemDefintion = factory.createItemDefinition();
>> >
>> > I can get eResource() from another object in this method, but how
>> can > I add the itemDefinition to the Resource?
>> >
>> > -- > Regards, Milan
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: EObject to String [message #508694 is a reply to message #508588] |
Tue, 19 January 2010 21:49 |
Milan Milanovich Messages: 201 Registered: July 2009 |
Senior Member |
|
|
Dear Mr. Merks,
good, thanks. I switched to XMI in genmodel and it works now...i.e., it is saved in XMI file. However, when I try to read the SimpleAnyType value I get an exception. I save like this:
Resource r =someObject.eResource();
SimpleAnyType ant = XMLTypeFactory.eINSTANCE.createSimpleAnyType();
ant.setInstanceType(EcorePackage.Literals.ESTRING);
ant.setValue(newCondition);
r.getContents().add(ant); // add to resource
this works well, however when I tried to load the value later:
SimpleAnyType ant = (SimpleAnyType)((FormalExpression) e).getBody();
String s = (String)ant.getValue(); <- here I get an exception:
java.lang.NullPointerException
at org.eclipse.emf.ecore.util.EcoreUtil.createFromString(EcoreUtil.java:3257)
at org.eclipse.emf.ecore.xml.type.impl.SimpleAnyTypeImpl.getValue(SimpleAnyTypeImpl.java:124)
what is the problem here?
--
Regards, Milan
[Updated on: Tue, 19 January 2010 21:51] Report message to a moderator
|
|
| | | |
Re: EObject to String [message #508855 is a reply to message #508850] |
Wed, 20 January 2010 14:58 |
Milan Milanovich Messages: 201 Registered: July 2009 |
Senior Member |
|
|
Dear Mr. Merks,
O.K., but where can I found XMLResource in this case?
Is it O.K. to do this in my PackageResourceImpl extends XMIResourceImpl constructor:
Map options = new HashMap();
options.put(XMIResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
save(options);
?
btw- I'm using XMI serialization now.
--
Regards, Milan
[Updated on: Wed, 20 January 2010 15:19] Report message to a moderator
|
|
| | | |
Re: EObject to String [message #508888 is a reply to message #508881] |
Wed, 20 January 2010 16:08 |
Milan Milanovich Messages: 201 Registered: July 2009 |
Senior Member |
|
|
Dear Mr. Merks,
I meant above...sorry. I repeat it here:
I put this code in my PackageResourceFactory:
Map options = new HashMap();
options.put(XMIResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
save(options);
However, the problem remains. Everything is written good with this code:
FormalExpression fe = (FormalExpression) e;
Resource r = fe.eResource();
SimpleAnyType ant = XMLTypeFactory.eINSTANCE.createSimpleAnyType();
ant.setInstanceType(EcorePackage.Literals.ESTRING);
ant.setValue(newCondition);
r.getContents().add(ant); // add to resource
...
fe.setBody(ant);
this is what I get in the model file (an excerpt):
....
<conditionExpression xsi:type="bpmn2_2:FormalExpression" language="ocl" evaluatesToTypeRef="/1" body="/2"/>
...
<bpmn2_2:ItemDefinition structure="/3"/>
<xsd:SimpleAnyType>
some string <instanceType href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</xsd:SimpleAnyType>
however, when I try to read this by using this code:
SimpleAnyType ant = (SimpleAnyType)((FormalExpression) e).getBody();
String s = (String)ant.getValue(); <- here I get an exception shown below
I get and exception:
java.lang.NullPointerException
at org.eclipse.emf.ecore.util.EcoreUtil.createFromString(EcoreUtil.java:3257)
at org.eclipse.emf.ecore.xml.type.impl.SimpleAnyTypeImpl.getValue(SimpleAnyTypeImpl.java:124)
at ca.athabascau.semtech.bpmn2.common.impl.SequenceFlowImpl.getCondition(SequenceFlowImpl.java:330)
...
--
Milan
[Updated on: Wed, 20 January 2010 16:43] Report message to a moderator
|
|
|
Re: EObject to String [message #508899 is a reply to message #508888] |
Wed, 20 January 2010 16:21 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------090404060803040702020805
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Milan,
Here's what the resource factory looks like for a model generated from
XML Schema:
/**
* Creates an instance of the resource.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Resource createResource(URI uri) {
XMLResource result = new LibraryResourceImpl(uri);
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA _LOCATION,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LE XICAL_HANDLER,
Boolean.TRUE);
return result;
}
Milan Milanovich wrote:
> Dear Mr. Merks,
> I meant above...sorry. I repeat it here:
>
> Is it O.K. to do this in my PackageResourceImpl extends
> XMIResourceImpl constructor:
>
> Map options = new HashMap();
>
> options.put(XMIResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
>
> save(options);
>
> ?
>
> --
> Milan
--------------090404060803040702020805
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Milan,<br>
<br>
Here's what the resource factory looks like for a model generated from
XML Schema:<br>
<blockquote><small> /**</small><br>
<small> * Creates an instance of the resource.</small><br>
<small> * <!-- begin-user-doc --></small><br>
<small> * <!-- end-user-doc --></small><br>
<small> * @generated</small><br>
<small> */</small><br>
<small> @Override</small><br>
<small> public Resource createResource(URI uri) {</small><br>
<small> XMLResource result = new LibraryResourceImpl(uri);</small><br>
<small>
result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
Boolean.TRUE);</small><br>
<small>
result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTEND ED_META_DATA,
Boolean.TRUE);</small><br>
<br>
<small>
result.getDefaultSaveOptions().put(XMLResource.OPTION_SCHEMA _LOCATION,
Boolean.TRUE);</small><br>
<br>
<small>
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
Boolean.TRUE);</small><br>
<small>
result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
Boolean.TRUE);</small><br>
<br>
<small>
result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LE XICAL_HANDLER,
Boolean.TRUE);</small><br>
<small> return result;</small><br>
<small> }</small><br>
</blockquote>
<br>
<br>
Milan Milanovich wrote:
<blockquote cite="mid:hj79qn$s7u$1@build.eclipse.org" type="cite">Dear
Mr. Merks, <br>
I meant above...sorry. I repeat it here:
<br>
<br>
Is it O.K. to do this in my PackageResourceImpl extends XMIResourceImpl
constructor:
<br>
<br>
Map options = new HashMap();
<br>
<br>
options.put(XMIResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE);
<br>
<br>
save(options);
<br>
<br>
?
<br>
<br>
--
<br>
Milan
<br>
</blockquote>
</body>
</html>
--------------090404060803040702020805--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | |
Re: EObject to String [message #508907 is a reply to message #508905] |
Wed, 20 January 2010 16:51 |
Milan Milanovich Messages: 201 Registered: July 2009 |
Senior Member |
|
|
Dear Mr. Merks,
I have updated my method and it now looks like this:
@Override
public Resource createResource(URI uri) {
XMIResource result= new CommonResourceImpl(uri);
result.getDefaultSaveOptions().put(XMIResource.OPTION_EXTENDED_META_DATA,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMIResource.OPTION_EXTENDED_META_DATA,
Boolean.TRUE);
result.getDefaultSaveOptions().put(XMIResource.OPTION_SCHEMA_LOCATION,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMIResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
result.getDefaultSaveOptions().put(XMIResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE,
Boolean.TRUE);
result.getDefaultLoadOptions().put(XMIResource.OPTION_USE_LEXICAL_HANDLER,
Boolean.TRUE);
return result;
}
however, I'm still gettng an exception when I try to get SimpleAnyType value, as I desribed here.
--
Thanks, Milan
|
|
|
Re: EObject to String [message #508912 is a reply to message #508907] |
Wed, 20 January 2010 17:11 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Milan,
What does the serialization look like?
Milan Milanovich wrote:
> Dear Mr. Merks,
>
> I have updated my method and it now looks like this:
>
> @Override
> public Resource createResource(URI uri) {
> XMIResource result= new CommonResourceImpl(uri);
>
>
> result.getDefaultSaveOptions().put(XMIResource.OPTION_EXTEND ED_META_DATA,
> Boolean.TRUE);
>
>
> result.getDefaultLoadOptions().put(XMIResource.OPTION_EXTEND ED_META_DATA,
> Boolean.TRUE);
>
>
> result.getDefaultSaveOptions().put(XMIResource.OPTION_SCHEMA _LOCATION,
> Boolean.TRUE);
>
>
> result.getDefaultLoadOptions().put(XMIResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
>
> Boolean.TRUE);
>
>
> result.getDefaultSaveOptions().put(XMIResource.OPTION_USE_EN CODED_ATTRIBUTE_STYLE,
>
> Boolean.TRUE);
>
>
> result.getDefaultLoadOptions().put(XMIResource.OPTION_USE_LE XICAL_HANDLER,
>
> Boolean.TRUE);
>
> return result;
> }
>
> however, I'm still gettng an exception when I try to get SimpleAnyType
> value, as I desribed
> http://www.eclipse.org/forums/index.php?t=msg&&th=16 0464&goto=508888#msg_508888
>
>
> --
> Thanks, Milan
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | |
Re: EObject to String [message #508935 is a reply to message #508932] |
Wed, 20 January 2010 18:40 |
Milan Milanovich Messages: 201 Registered: July 2009 |
Senior Member |
|
|
Dear Mr. Merks,
Ed Merks wrote on Wed, 20 January 2010 12:40 | Milan,
That looks okay, but not what I'd expect. The stack trace you show
makes it sound like the instanceType is null though, but I'd expect it
to be set based on what I see below. One thing that seems problematic
though is that the instanceType reference is cross document and yet the
instanceType feature doesn't do cross document proxy resolution. It's
generally expected that the serialization would be using a containing
element along with an xsi:type but given you're putting this at the root
of a document, there is no good element name to use. I think the best
approach would be to define some type of "ValueContainer" EClass with a
containment reference to EObject and to nest all these "free floating
values" inside that container which in turn is nested at the root of the
resource.
|
Actually, the instanceType is not null, but the value. If I try to read the instance type I get:
org.eclipse.emf.ecore.impl.EDataTypeImpl@1092e60 (eProxyURI: http://www.eclipse.org/emf/2002/Ecore#//EString)
so it's not null.
I'm what is the ValueContainer eclass, but when I set the body (of SimpleAnyType) to my FormalExpression instance, it is already initialized by using the seq initializer in gmfmap.
One general question regarding this subject, i.e., non-containament references which are not defined graphically in gmf, e.g.:
class SequenceFlow{
expression[0..1]: Expression;
}
class FormalExpression extends Expression { <- this class is not defined graphically
body : EObject;
language : EString;
}
I want to enable that when a user clicks on the SequenceFlow, he can define its expression, by instantiating
the FormalExpression and populating the body with empty String and the language with asting. Then, user
should enter body of the FormalExpression. This is maybe GMF related question, but I want to ask you what strategy do you recommend me (example?) ?
--
thanks, Milan
[Updated on: Wed, 20 January 2010 18:45] Report message to a moderator
|
|
|
Re: EObject to String [message #508937 is a reply to message #508935] |
Wed, 20 January 2010 18:47 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Milan,
Comments below.
Milan Milanovich wrote:
> Dear Mr. Merks,
>
> Ed Merks wrote on Wed, 20 January 2010 12:40
>> Milan,
>>
>> That looks okay, but not what I'd expect. The stack trace you show
>> makes it sound like the instanceType is null though, but I'd expect
>> it to be set based on what I see below. One thing that seems
>> problematic though is that the instanceType reference is cross
>> document and yet the instanceType feature doesn't do cross document
>> proxy resolution. It's generally expected that the serialization
>> would be using a containing element along with an xsi:type but given
>> you're putting this at the root of a document, there is no good
>> element name to use. I think the best approach would be to define
>> some type of "ValueContainer" EClass with a containment reference to
>> EObject and to nest all these "free floating values" inside that
>> container which in turn is nested at the root of the resource.
>
>
> Actually, the instanceType is not null, but the value. If I try to
> read the instance type I get:
>
> mailto:org.eclipse.emf.ecore.impl.EDataTypeImpl@1092e60 (eProxyURI:
> http://www.eclipse.org/emf/2002/Ecore#//EString)
>
> so it's not null.
Yes, as I said, that feature doesn't try to resolve proxies but the
serialization would result in a proxy being created.
>
> I'm what is the ValueContainer eclass, but when I set body (of
> SimpleAnyType) to my FormalExpression instance, it is already
> initialized by using seq initializer in gmfmap.
> One general question regarding this subject, i.e., non-containament
> references which are not defined graphically in gmf, e.g.:
>
> class SequenceFlow{
> expression[0..1]: Expression;
> }
>
> class FormalExpression extends Expression { <- this class is not
> defined graphically
> body : EObject;
> language : EString;
> }
>
> I want to enable that when a user click on the SequenceFlow, he can
> define its expression, by instantiating
> the FormalExpression and populating body with empty String and
> language with some other sting. Then, user
> should enter body of the FormalExpression. This is maybe GMF related
> question, but I want to ask you what strategy do you recommend me
> (example?) ?
>
It's a GMF question for which I don't know the answer.
>
> --
> thanks, Milan
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: EObject to String [message #508952 is a reply to message #508939] |
Wed, 20 January 2010 20:25 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Milan,
Comments below.
Milan Milanovich wrote:
> Dear Mr. Merks,
>
> O.K. Thank you. Regarding this:
>
> Ed Merks wrote on Wed, 20 January 2010 12:40
>> Milan,
>>
>> That looks okay, but not what I'd expect. The stack trace you show
>> makes it sound like the instanceType is null though, but I'd expect
>> it to be set based on what I see below. One thing that seems
>> problematic though is that the instanceType reference is cross
>> document and yet the instanceType feature doesn't do cross document
>> proxy resolution. It's generally expected that the serialization
>> would be using a containing element along with an xsi:type but given
>> you're putting this at the root of a document, there is no good
>> element name to use. I think the best approach would be to define
>> some type of "ValueContainer" EClass with a containment reference to
>> EObject and to nest all these "free floating values" inside that
>> container which in turn is nested at the root of the resource.
>
>
> I have a top-most element of my model called Collaboration, which have
> containment reference to a Definitions object. This Definitions object
> is intended to be used for defining some types. It definition looks
> like this:
>
> class Definitions {
I tend to have an aversion to classes with a puralized name because it's
very hard to create well formed English sentence from such nouns. You
create a Definitions. What if there are two Definitions as opposed to
just one.
> targetNamespace : EString;
> typeLanguage : EString;
> rootElements : RootElement;
> imports : Import;
> extensions : Extension;
> }
>
> Is this class good candidate for the " ValueContainer" EClass ? Or
> should I add it one EObject[0..*] containment reference to hold all of
> the SimpleValueTypes?
Yes, you need some type of EObject containment reference somewhere.
>
> --
> thanks, Milan
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Tue Sep 24 00:37:40 GMT 2024
Powered by FUDForum. Page generated in 0.06567 seconds
|