|
Re: [XSD2Ecore] is removing removing underscore from EEnumLiteral name and not setting literal [message #984738 is a reply to message #984678] |
Wed, 14 November 2012 23:28 |
David Rees Messages: 47 Registered: September 2012 |
Member |
|
|
The same problem is happening with dash separated literal names as well. In the dash case the dashes do have to be removed to make them valid Java names, but in that case the literal should have the "unaltered value of the enumeration facet" according to 9.2.2 in the EMF book, correct?
Here is a dash example:
<xsd:simpleType name="VALID-TYPE">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="VALID"/>
<xsd:enumeration value="NOT-VALID"/>
<xsd:enumeration value="NOT-DEFINED"/>
<xsd:enumeration value="NOT-AVAILABLE"/>
</xsd:restriction>
</xsd:simpleType>
enum VALIDTYPE {
VALID = 0;
NOTVALID = 1;
NOTDEFINED = 2;
NOTAVAILABLE = 3;
}
Thanks,
dave
[Updated on: Wed, 14 November 2012 23:29] Report message to a moderator
|
|
|
Re: [XSD2Ecore] is removing removing underscore from EEnumLiteral name and not setting literal [message #985005 is a reply to message #984678] |
Thu, 15 November 2012 04:39 |
Ed Merks Messages: 33137 Registered: July 2009 |
Senior Member |
|
|
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
David,<br>
<br>
Comments below.<br>
<br>
<div class="moz-cite-prefix">On 14/11/2012 11:21 PM, David Rees
wrote:<br>
</div>
<blockquote cite="mid:k815gn$q1u$1@xxxxxxxxe.org" type="cite">I'm
running into a name mapping problem where XSD2Ecore is mapping an
Restriction with Enumeration Facets to an EENum. Each enumeration
value has an underscore, but the corresponding EEnumLiteral's name
has the underscore removed and the it's literal is not properly
set to original value either. </blockquote>
No, the literal is set properly.<br>
<br>
/**<br>
* The '<em><b>AFLOAT</b></em>' literal
value.<br>
* <!-- begin-user-doc --><br>
* <p><br>
* If the meaning of
'<em><b>AFLOAT</b></em>' literal object
isn't clear,<br>
* there really should be more of a description here...<br>
* </p><br>
* <!-- end-user-doc --><br>
* @see #AFLOAT<br>
<b> * @model literal="A_FLOAT"</b><br>
* @generated<br>
* @ordered<br>
*/<br>
public static final int AFLOAT_VALUE = 0;<br>
<br>
<blockquote cite="mid:k815gn$q1u$1@xxxxxxxxe.org" type="cite">I'll
add I don't think removing the underscore should be required to
make it a valid Java name anyway.
<br>
</blockquote>
Technically the name is valid as long as it doesn't contain
characters that aren't valid Java characters and NCName allows many
such characters. But in general we convert names to use Camel
casee...<br>
<blockquote cite="mid:k815gn$q1u$1@xxxxxxxxe.org" type="cite">
<br>
Is this a bug or am I missing an option somewhere?
<br>
</blockquote>
That's just how it works. You can use Ecore annotations to specify
exactly the name you want.<br>
<blockquote cite="mid:k815gn$q1u$1@xxxxxxxxe.org" type="cite">
<br>
Thanks,
<br>
dave
<br>
<br>
Here is the XSD snippet:
<br>
<br>
<xsd:simpleType name="DATA-TYPE">
<br>
<xsd:restriction base="xsd:string">
<br>
<xsd:enumeration value="A_INT32"/>
<br>
<xsd:enumeration value="A_UINT32"/>
<br>
<xsd:enumeration value="A_FLOAT32"/>
<br>
<xsd:enumeration value="A_FLOAT64"/>
<br>
<xsd:enumeration value="A_ASCIISTRING"/>
<br>
<xsd:enumeration value="A_UTF8STRING"/>
<br>
<xsd:enumeration value="A_UNICODE2STRING"/>
<br>
<xsd:enumeration value="A_BYTEFIELD"/>
<br>
</xsd:restriction>
<br>
</xsd:simpleType>
<br>
<br>
<br>
And here is generated Ecore (in OCLinEcore):
<br>
<br>
enum DATATYPE { serializable }
<br>
{
<br>
annotation
_'<a class="moz-txt-link-freetext" href="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">http:///org/eclipse/emf/ecore/util/ExtendedMetaData</a>'
<br>
(
<br>
name = 'DATA-TYPE'
<br>
);
<br>
literal AINT32;
<br>
literal AUINT32 = 1;
<br>
literal AFLOAT32 = 2;
<br>
literal AFLOAT64 = 3;
<br>
literal AASCIISTRING = 4;
<br>
literal AUTF8STRING = 5;
<br>
literal AUNICODE2STRING = 6;
<br>
literal ABYTEFIELD = 7;
<br>
}
<br>
<br>
</blockquote>
It looks like they're not converting the literal value.<br>
<blockquote cite="mid:k815gn$q1u$1@xxxxxxxxe.org" type="cite">
<br>
Thanks,
<br>
dave
<br>
</blockquote>
<br>
</body>
</html>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02918 seconds