Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » TODO: The default literal value "EnumMemberA" is invalid
TODO: The default literal value "EnumMemberA" is invalid [message #76307] Thu, 13 November 2008 11:52 Go to next message
John T.E. Timm is currently offline John T.E. Timm
Messages: 160
Registered: July 2009
Senior Member
I am having a problem with an attribute that is defined as fixed with a
simple type enumeration member:

<xs:attribute name="attr1" type="SimpleTypeA" fixed="EnumMemberA"/>

is generating:

protected static final Object ATTR1_EDEFAULT; // TODO The default value
literal "EnumMemberA" is not valid.
protected Object attr1 = ATTR1_EDEFAULT;

The causes a compilation error for unassigned static final field. I
believe that in the past (perhaps version EMF 2.2) it would have generated
this:

protected static final Object ATTR1_EDEFAULT =
ExampleFactory.eINSTANCE.createFromString(ExamplePackage.eIN STANCE.getSimpleTypeA(),
"EnumMemberA");
protected Object attr1 = ATTR1_EDEFAULT;

The full schema that was used for this example is:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.org"
xmlns="http://example.org">

<xs:simpleType name="SimpleBaseType">
<xs:restriction base="xs:token">
<xs:pattern value="[^\s]+"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="SimpleTypeA">
<xs:union memberTypes="SimpleTypeB SimpleTypeC"/>
</xs:simpleType>

<xs:simpleType name="SimpleTypeB">
<xs:restriction base="SimpleBaseType"/>
</xs:simpleType>

<xs:simpleType name="SimpleTypeC">
<xs:restriction base="SimpleBaseType">
<xs:enumeration value="EnumMemberA"/>
<xs:enumeration value="EnumMemberB"/>
<xs:enumeration value="EnumMemberC"/>
</xs:restriction>
</xs:simpleType>

<xs:complexType name="ComplexTypeA">
<xs:sequence>
<xs:element name="element1" type="xs:string"/>
<xs:element name="element2" type="xs:string"/>
</xs:sequence>
<xs:attribute name="attr1" type="SimpleTypeA" fixed="EnumMemberA"/>
</xs:complexType>

</xs:schema>

I am running Eclipse Ganymede 3.4.1 with EMF 2.4.1 on Windows XP SP3.

Thanks,

John
Re: TODO: The default literal value "EnumMemberA" is invalid [message #76341 is a reply to message #76307] Thu, 13 November 2008 12:59 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25739
Registered: July 2009
Senior Member
John,

I see, because it's a union without a common base type. Please open a
bugzilla with this example and I'll look into fixing it.


John T.E. Timm wrote:
> I am having a problem with an attribute that is defined as fixed with
> a simple type enumeration member:
>
> <xs:attribute name="attr1" type="SimpleTypeA" fixed="EnumMemberA"/>
>
> is generating:
>
> protected static final Object ATTR1_EDEFAULT; // TODO The default
> value literal "EnumMemberA" is not valid.
> protected Object attr1 = ATTR1_EDEFAULT;
>
> The causes a compilation error for unassigned static final field. I
> believe that in the past (perhaps version EMF 2.2) it would have
> generated this:
>
> protected static final Object ATTR1_EDEFAULT =
> ExampleFactory.eINSTANCE.createFromString(ExamplePackage.eIN STANCE.getSimpleTypeA(),
> "EnumMemberA");
> protected Object attr1 = ATTR1_EDEFAULT;
>
> The full schema that was used for this example is:
>
> <?xml version="1.0"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://example.org"
> xmlns="http://example.org">
>
> <xs:simpleType name="SimpleBaseType">
> <xs:restriction base="xs:token">
> <xs:pattern value="[^\s]+"/>
> </xs:restriction>
> </xs:simpleType>
>
> <xs:simpleType name="SimpleTypeA">
> <xs:union memberTypes="SimpleTypeB SimpleTypeC"/>
> </xs:simpleType>
>
> <xs:simpleType name="SimpleTypeB">
> <xs:restriction base="SimpleBaseType"/>
> </xs:simpleType>
>
> <xs:simpleType name="SimpleTypeC">
> <xs:restriction base="SimpleBaseType">
> <xs:enumeration value="EnumMemberA"/>
> <xs:enumeration value="EnumMemberB"/>
> <xs:enumeration value="EnumMemberC"/>
> </xs:restriction>
> </xs:simpleType>
>
> <xs:complexType name="ComplexTypeA">
> <xs:sequence>
> <xs:element name="element1" type="xs:string"/>
> <xs:element name="element2" type="xs:string"/>
> </xs:sequence>
> <xs:attribute name="attr1" type="SimpleTypeA" fixed="EnumMemberA"/>
> </xs:complexType>
>
> </xs:schema>
>
> I am running Eclipse Ganymede 3.4.1 with EMF 2.4.1 on Windows XP SP3.
>
> Thanks,
>
> John
>
Re: TODO: The default literal value "EnumMemberA" is invalid [message #603475 is a reply to message #76307] Thu, 13 November 2008 12:59 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25739
Registered: July 2009
Senior Member
John,

I see, because it's a union without a common base type. Please open a
bugzilla with this example and I'll look into fixing it.


John T.E. Timm wrote:
> I am having a problem with an attribute that is defined as fixed with
> a simple type enumeration member:
>
> <xs:attribute name="attr1" type="SimpleTypeA" fixed="EnumMemberA"/>
>
> is generating:
>
> protected static final Object ATTR1_EDEFAULT; // TODO The default
> value literal "EnumMemberA" is not valid.
> protected Object attr1 = ATTR1_EDEFAULT;
>
> The causes a compilation error for unassigned static final field. I
> believe that in the past (perhaps version EMF 2.2) it would have
> generated this:
>
> protected static final Object ATTR1_EDEFAULT =
> ExampleFactory.eINSTANCE.createFromString(ExamplePackage.eIN STANCE.getSimpleTypeA(),
> "EnumMemberA");
> protected Object attr1 = ATTR1_EDEFAULT;
>
> The full schema that was used for this example is:
>
> <?xml version="1.0"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://example.org"
> xmlns="http://example.org">
>
> <xs:simpleType name="SimpleBaseType">
> <xs:restriction base="xs:token">
> <xs:pattern value="[^\s]+"/>
> </xs:restriction>
> </xs:simpleType>
>
> <xs:simpleType name="SimpleTypeA">
> <xs:union memberTypes="SimpleTypeB SimpleTypeC"/>
> </xs:simpleType>
>
> <xs:simpleType name="SimpleTypeB">
> <xs:restriction base="SimpleBaseType"/>
> </xs:simpleType>
>
> <xs:simpleType name="SimpleTypeC">
> <xs:restriction base="SimpleBaseType">
> <xs:enumeration value="EnumMemberA"/>
> <xs:enumeration value="EnumMemberB"/>
> <xs:enumeration value="EnumMemberC"/>
> </xs:restriction>
> </xs:simpleType>
>
> <xs:complexType name="ComplexTypeA">
> <xs:sequence>
> <xs:element name="element1" type="xs:string"/>
> <xs:element name="element2" type="xs:string"/>
> </xs:sequence>
> <xs:attribute name="attr1" type="SimpleTypeA" fixed="EnumMemberA"/>
> </xs:complexType>
>
> </xs:schema>
>
> I am running Eclipse Ganymede 3.4.1 with EMF 2.4.1 on Windows XP SP3.
>
> Thanks,
>
> John
>
Previous Topic:Generated EObjectValidator class
Next Topic:Generated EObjectValidator class
Goto Forum:
  


Current Time: Wed Apr 16 00:31:21 EDT 2014

Powered by FUDForum. Page generated in 0.09091 seconds