Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF/Databinding] xsd:choice attribute
[EMF/Databinding] xsd:choice attribute [message #830360] Tue, 27 March 2012 14:34 Go to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi there,

I have this requirement, that I need to hold different types into a collection and maintain the order.

As I always start from xsd, I modelled it like this:

...
<xs:sequence>
                <xs:choice maxOccurs="1">
		       <xs:element name="ReferenceRelationship" ecore:reference="library:ReferenceRelationship" type="xs:anyURI">
		       </xs:element>
		       <xs:element name="ServiceFlow" ecore:reference="ServiceFlow" type="xs:anyURI">
		       </xs:element>
		</xs:choice>
</xs:sequence>
...


I was somewhat surprised to see, I get two features, for the EClass from this complextype (omitted in the snippet), when generating the model code.

So now I wonder, if there is alternative to achieve the same thing, and whereby only one EStructuralFeature is created for the choice?

The reason, is that with databinding two features is problematic in the case of a ObservableValueEditingSupport, which binds early on a feature, and can't really retarget the binding to another feature when editing a list holding both possible choices.


Thank you,
Christophe Bouhier

Re: [EMF/Databinding] xsd:choice attribute [message #830522 is a reply to message #830360] Tue, 27 March 2012 18:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Christophe,

Comments below.

On 27/03/2012 10:34 AM, Christophe Bouhier wrote:
> Hi there,
> I have this requirement, that I need to hold different types into a
> collection and maintain the order.
> As I always start from xsd, I modelled it like this:
>
> ..
> <xs:sequence>
> <xs:choice maxOccurs="1">
The default for maxOccurs is one anyway. You said you needed a
collection though...
> <xs:element name="ReferenceRelationship"
> ecore:reference="library:ReferenceRelationship" type="xs:anyURI">
> </xs:element>
> <xs:element name="ServiceFlow" ecore:reference="ServiceFlow"
> type="xs:anyURI">
> </xs:element>
> </xs:choice>
> </xs:sequence>
> ..
>
>
> I was somewhat surprised to see, I get two features, for the EClass
> from this complextype (omitted in the snippet), when generating the
> model code.
Well, there's no such thing as a choice in Ecore itself.
> So now I wonder, if there is alternative to achieve the same thing,
> and whereby only one EStructuralFeature is created for the choice?
Not really. You could add a named constraint that's implements so it's
only valid to populate one of the two features.
> The reason, is that with databinding two features is problematic in
> the case of a ObservableValueEditingSupport, which binds early on a
> feature, and can't really retarget the binding to another feature when
> editing a list holding both possible choices.
I'm not sure what to suggest for that...
>
> Thank you, Christophe Bouhier
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF/Databinding] xsd:choice attribute [message #830933 is a reply to message #830522] Wed, 28 March 2012 08:37 Go to previous message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Thanks Ed.
I solved the problem differently on the UI side.
rgds Christophe
Previous Topic:XML processing instruction with EMF 2.2
Next Topic:[EMF] feature edit parameters incorrect in .genmodel
Goto Forum:
  


Current Time: Thu Apr 25 22:41:32 GMT 2024

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

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

Back to the top