Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » 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 16:52 Go to next message
John T.E. Timm is currently offline John T.E. TimmFriend
Messages: 161
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 17:59 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
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
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: TODO: The default literal value "EnumMemberA" is invalid [message #603475 is a reply to message #76307] Thu, 13 November 2008 17:59 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
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
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Generated EObjectValidator class
Next Topic:Generated EObjectValidator class
Goto Forum:
  


Current Time: Sat Apr 20 03:43:30 GMT 2024

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

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

Back to the top