[XSD2Ecore] is removing removing underscore from EEnumLiteral name and not setting literal [message #984678] |
Wed, 14 November 2012 17:21  |
Eclipse User |
|
|
|
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. I'll add I don't think removing the underscore should be required to make it a valid Java name anyway.
Is this a bug or am I missing an option somewhere?
Thanks,
dave
Here is the XSD snippet:
<xsd:simpleType name="DATA-TYPE">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="A_INT32"/>
<xsd:enumeration value="A_UINT32"/>
<xsd:enumeration value="A_FLOAT32"/>
<xsd:enumeration value="A_FLOAT64"/>
<xsd:enumeration value="A_ASCIISTRING"/>
<xsd:enumeration value="A_UTF8STRING"/>
<xsd:enumeration value="A_UNICODE2STRING"/>
<xsd:enumeration value="A_BYTEFIELD"/>
</xsd:restriction>
</xsd:simpleType>
And here is generated Ecore (in OCLinEcore):
enum DATATYPE { serializable }
{
annotation _'http:///org/eclipse/emf/ecore/util/ExtendedMetaData'
(
name = 'DATA-TYPE'
);
literal AINT32;
literal AUINT32 = 1;
literal AFLOAT32 = 2;
literal AFLOAT64 = 3;
literal AASCIISTRING = 4;
literal AUTF8STRING = 5;
literal AUNICODE2STRING = 6;
literal ABYTEFIELD = 7;
}
Thanks,
dave
|
|
|
|
Re: [XSD2Ecore] is removing removing underscore from EEnumLiteral name and not setting literal [message #985005 is a reply to message #984678] |
Wed, 14 November 2012 23:39  |
Eclipse User |
|
|
|
<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>
|
|
|
Powered by
FUDForum. Page generated in 0.03387 seconds