XSD to Ecore <xsd:choise> management [message #427267] |
Tue, 10 February 2009 04:19  |
Eclipse User |
|
|
|
Hello everyone,
I have seen a lot of posts speaking about this question, but I don't find
a solution to resolve it.
Indeed, I have in my XSD :
<xsd:choice>
<xsd:element name="element1" type="xsd:string" />
<xsd:element name="element2" type="xsd:string" />
<xsd:element name="element3" type="xsd:string" />
</xsd:choice>
but I have nothing in the ecore to manage this constraint. In in my editor
I can add the tree element in the same time, but when I validate, it find
that there is a problem as only one element must be present.
How can I resolve it?
Thx,
David.
|
|
|
Re: XSD to Ecore <xsd:choise> management [message #427268 is a reply to message #427267] |
Tue, 10 February 2009 07:37   |
Eclipse User |
|
|
|
David,
Comments below.
David wrote:
> Hello everyone,
> I have seen a lot of posts speaking about this question, but I don't
> find a solution to resolve it.
> Indeed, I have in my XSD : <xsd:choice>
> <xsd:element name="element1" type="xsd:string" />
> <xsd:element name="element2" type="xsd:string" />
> <xsd:element name="element3" type="xsd:string" />
> </xsd:choice>
>
> but I have nothing in the ecore to manage this constraint. In in my
> editor I can add the tree element in the same time, but when I
> validate, it find that there is a problem as only one element must be
> present.
>
> How can I resolve it?
Don't add more than one element. :-P
Even if you add a constraint, the editor will still let you add/set it,
but at least it will complain when you invoke "Validate...". You can
add a constraint via an ecore:constraints="Blah" on the containing
complex type Abc. This will generate a method validateAbc_Blah in the
XyzValidator that you can use to enforce the mutual exclusiveness.
You'll still need to make specializations in the commands produced by
the AbcItemProvider. You might for example create a compound command
that unsets the other feature or you might disable the command forcing
the other feature to be unset first.
>
> Thx,
> David.
>
|
|
|
|
|
|
Re: XSD to Ecore <xsd:choise> management [message #427294 is a reply to message #427291] |
Wed, 11 February 2009 07:52  |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
--------------090403070706090109010709
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
David,
Comments below.
David wrote:
> Thanks Ed,
>
> What kind of annotations can I add to the XSD to manage my constraint?
Using ecore:constraints as I suggested already:
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/references/overview/EMF.Validation.html
>
> If I modify the item provider's class CreateChildCommand, the action
> is not add to the new child actions. And I would like to have the
> action present in the context menu and that it is grayed.
I had something like this in mind:
protected Command createCreateChildCommand
(EditingDomain domain, EObject owner, EStructuralFeature
feature, Object value, int index, Collection<?> collection)
{
return
new CreateChildCommand(domain, owner, feature, value, index,
collection, this)
{
@Override
protected boolean prepare()
{
return super.prepare() && shouldItReallyBeAllowed();
}
};
}
> David.
>
--------------090403070706090109010709
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
David,<br>
<br>
Comments below.<br>
<br>
<br>
David wrote:
<blockquote
cite="mid:962dc662bb5c4d7c7d4da915e8d28faf$1@www.eclipse.org"
type="cite">Thanks Ed,
<br>
<br>
What kind of annotations can I add to the XSD to manage my constraint?
<br>
</blockquote>
Using ecore:constraints as I suggested already:
|
|
|
Powered by
FUDForum. Page generated in 0.03602 seconds