Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [XSD2Ecore] is removing removing underscore from EEnumLiteral name and not setting literal
[XSD2Ecore] is removing removing underscore from EEnumLiteral name and not setting literal [message #984678] Wed, 14 November 2012 22:21 Go to next message
David Rees is currently offline David ReesFriend
Messages: 47
Registered: September 2012
Member
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 #984738 is a reply to message #984678] Wed, 14 November 2012 23:28 Go to previous messageGo to next message
David Rees is currently offline David ReesFriend
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 Go to previous message
Ed Merks is currently offline Ed MerksFriend
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 '&lt;em&gt;&lt;b&gt;AFLOAT&lt;/b&gt;&lt;/em&gt;' literal
value.<br>
   * &lt;!-- begin-user-doc --&gt;<br>
   * &lt;p&gt;<br>
   * If the meaning of
'&lt;em&gt;&lt;b&gt;AFLOAT&lt;/b&gt;&lt;/em&gt;' literal object
isn't clear,<br>
   * there really should be more of a description here...<br>
   * &lt;/p&gt;<br>
   * &lt;!-- end-user-doc --&gt;<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>
   &lt;xsd:simpleType name="DATA-TYPE"&gt;
<br>
       &lt;xsd:restriction base="xsd:string"&gt;
<br>
           &lt;xsd:enumeration value="A_INT32"/&gt;
<br>
           &lt;xsd:enumeration value="A_UINT32"/&gt;
<br>
           &lt;xsd:enumeration value="A_FLOAT32"/&gt;
<br>
           &lt;xsd:enumeration value="A_FLOAT64"/&gt;
<br>
           &lt;xsd:enumeration value="A_ASCIISTRING"/&gt;
<br>
           &lt;xsd:enumeration value="A_UTF8STRING"/&gt;
<br>
           &lt;xsd:enumeration value="A_UNICODE2STRING"/&gt;
<br>
           &lt;xsd:enumeration value="A_BYTEFIELD"/&gt;
<br>
       &lt;/xsd:restriction&gt;
<br>
   &lt;/xsd:simpleType&gt;
<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/
Previous Topic:Problem referencing another emf project
Next Topic:[CDO] CDOAdmin - NullPointerException on Server side using TCP connector
Goto Forum:
  


Current Time: Sat Apr 20 02:35:33 GMT 2024

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

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

Back to the top