Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Newbie] <xsd:choice> representation
[Newbie] <xsd:choice> representation [message #419757] Thu, 05 June 2008 17:29 Go to next message
Nicola Salvo is currently offline Nicola SalvoFriend
Messages: 42
Registered: July 2009
Member
Hello,

I'm trying to model a xsd file with Java annotations. I don't know how to
express this piece of code:

<xsd:complexType>
<xsd:choice>
<xsd:element name="inputStream" type="tns:InputStreamType"/>
<xsd:element name="inputLiteral" type="tns:DataType"
maxOccurs="unbounded"/>
</xsd:choice>
<xsd:attribute name="name" type="xsd:string" use="required"/>
</xsd:complexType>

..
..
..
<xsd:complexType name="DataType">
<xsd:choice>
<xsd:element name="string" type="xsd:string"/>
<xsd:element name="charArray" type="xsd:string"/>
<xsd:.
element name="binary" type="xsd:base64Binary"/>
<xsd:element name="float" type="xsd:float"/>
<xsd:element name="double" type="xsd:double"/>
<xsd:element name="int" type="xsd:int"/>
<xsd:element name="long" type="xsd:long"/>
<xsd:element name="boolean" type="xsd:boolean"/>
<xsd:element name="date" type="xsd:dateTime"/>
<xsd:element name="listBegin" type="tns:ListBeginType"/>
<xsd:element name="listEnd" type="tns:ListEndType"/>
</xsd:choice>
</xsd:complexType>

I suppose I have to use EAnnotation, and for the second choice block I did:

/**
* @model
*/
public interface DataType extends EEnumLiteral{
/**
* @model dataType="org.eclipse.emf.ecore.xml.type.String"
* annotation="EAnnotation0 exclusion='charArray binary float
double int long'"
* @generated not
*/
String getString();


/**
* @see gsoc.ogsadai.model.ModelPackage#getDataType_CharArray()
* @model dataType="org.eclipse.emf.ecore.xml.type.String"
* annotation="EAnnotation0 exclusion='string binary float double
int long'"
* @generated not
*/
String getCharArray();
..
..
}

Is this approach correct? In the model editor the class is displayed with
all the attributes, but I suppose that the correct behavior will be a drop
down menu that let the user choose only one of the options.
Sorry for the long post, I searched I little but int he archive but I have
still the problem.
Cheers

Nicola
Re: [Newbie] <xsd:choice> representation [message #419758 is a reply to message #419757] Thu, 05 June 2008 18:54 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33216
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030902010607030309000400
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Nicola,

Comments below.

Nicola Salvo wrote:
> Hello,
>
> I'm trying to model a xsd file with Java annotations. I don't know how
> to express this piece of code:
>
> <xsd:complexType>
> <xsd:choice>
> <xsd:element name="inputStream" type="tns:InputStreamType"/>
> <xsd:element name="inputLiteral" type="tns:DataType"
> maxOccurs="unbounded"/>
> </xsd:choice>
> <xsd:attribute name="name" type="xsd:string" use="required"/>
> </xsd:complexType>
There isn't any way to express this in Ecore.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=51210

If you try importing such a model and then exporting it to a schema
(which is a handy way to see the @model annotations that correspond to
any particular type of schema construct) you'll see it ends up coming
out as <xsd:sequence/>
>
> ..
> ..
> ..
> <xsd:complexType name="DataType">
> <xsd:choice>
> <xsd:element name="string" type="xsd:string"/>
> <xsd:element name="charArray" type="xsd:string"/>
> <xsd:.
> element name="binary" type="xsd:base64Binary"/> <xsd:element
> name="float" type="xsd:float"/> <xsd:element name="double"
> type="xsd:double"/> <xsd:element name="int" type="xsd:int"/>
> <xsd:element name="long" type="xsd:long"/> <xsd:element
> name="boolean" type="xsd:boolean"/> <xsd:element name="date"
> type="xsd:dateTime"/> <xsd:element name="listBegin"
> type="tns:ListBeginType"/>
> <xsd:element name="listEnd" type="tns:ListEndType"/>
> </xsd:choice>
> </xsd:complexType>
>
> I suppose I have to use EAnnotation, and for the second choice block I
> did:
>
> /**
> * @model */
> public interface DataType extends EEnumLiteral{
> /**
> * @model dataType="org.eclipse.emf.ecore.xml.type.String"
> * annotation="EAnnotation0 exclusion='charArray binary
> float double int long'"
> * @generated not
> */
> String getString();
>
>
> /**
> * @see gsoc.ogsadai.model.ModelPackage#getDataType_CharArray()
> * @model dataType="org.eclipse.emf.ecore.xml.type.String"
> * annotation="EAnnotation0 exclusion='string binary float
> double int long'"
> * @generated not
> */
> String getCharArray();
> ..
> ..
> }
>
> Is this approach correct? In the model editor the class is displayed
> with all the attributes, but I suppose that the correct behavior will
> be a drop down menu that let the user choose only one of the options.
> Sorry for the long post, I searched I little but int he archive but I
> have still the problem.
You'll find the issue of choice comes up fairly frequently and the above
bugzilla is our oldest bugzilla. But it's also a tough problem to solve
in general, given that choice is not well supported in EMOF, UML, and
Java...

So it seems best to consider these just to be separate features that you
constrain to be mutually exclusive...
> Cheers
>
> Nicola
>


--------------030902010607030309000400
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">
Nicola,<br>
<br>
Comments below.<br>
<br>
Nicola Salvo wrote:
<blockquote
cite="mid:fb65cc113f2b5c5dd21ad98f7957903f$1@www.eclipse.org"
type="cite">Hello,
<br>
<br>
I'm trying to model a xsd file with Java annotations. I don't know how
to express this piece of code:
<br>
<br>
&lt;xsd:complexType&gt;
<br>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Hanging-up of model editor windows
Next Topic:Editin an EMF Model in a dialog
Goto Forum:
  


Current Time: Sat Sep 21 09:51:50 GMT 2024

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

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

Back to the top