Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Restriction Of Complex Types Not Validating(EMF does not appear to support Restriction Of Complex Types)
Restriction Of Complex Types Not Validating [message #629514] Tue, 28 September 2010 14:39 Go to next message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
I have found an issue which seems to imply that EMF does not support Restrictions of Complex types in terms of validation.

Given the following schema:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://example.com/ComplexRestriction" targetNamespace="http://example.com/ComplexRestriction">
    <!-- base type -->
    <xs:complexType name="BaseInfo">
        <xs:sequence>
            <xs:element name="numPosts" type="xs:integer" minOccurs="0" maxOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="firstSubscribed" type="xs:date" use="optional"/>
        <xs:attribute name="mailReader" type="xs:string"/>
    </xs:complexType>
    <!-- derived type -->
    <xs:complexType name="RestrictedOne">
        <xs:complexContent>
            <xs:restriction base="BaseInfo">
                <xs:sequence>
                    <xs:element name="numPosts" type="xs:integer" minOccurs="1"/>
                </xs:sequence>
                <xs:attribute name="firstSubscribed" type="xs:date" use="required"/>
                <xs:attribute name="mailReader" type="xs:string" fixed="Microsoft Outlook"/>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="NoBaseRestricted">
        <xs:sequence>
            <xs:element name="numPosts" type="xs:integer" minOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="firstSubscribed" type="xs:date" use="required"/>
        <xs:attribute name="mailReader" type="xs:string" fixed="Microsoft Outlook"/>
    </xs:complexType>
</xs:schema>


Now if you try:

NoBaseRestricted noBaseRestricted = RestrictionFactory.eINSTANCE.createNoBaseRestricted();
noBaseRestricted.setMailReader("Thunderbird");
Diagnostician.INSTANCE.validate(noBaseRestricted );


Then you get an error as expected because "firstSubscribed" is not set.

However if you do the following:

RestrictedOne restrictedOne = RestrictionFactory.eINSTANCE.createRestrictedOne();
restrictedOne.setMailReader("Thunderbird");
Diagnostician.INSTANCE.validate(restrictedOne);


Then there is no failure on the validation as would be expected. (It should fail as firstSubscribed is still not set)

Is this a know issue for EMF?

Thanks
Rob
Re: Restriction Of Complex Types Not Validating [message #629635 is a reply to message #629514] Wed, 29 September 2010 03:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Rob,

comments below.

Rob wrote:
> I have found an issue which seems to imply that EMF does not support
> Restrictions of Complex types in terms of validation.
Nope, it doesn't.
>
> Given the following schema:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns="http://example.com/ComplexRestriction"
> targetNamespace="http://example.com/ComplexRestriction">
> <!-- base type -->
> <xs:complexType name="BaseInfo">
> <xs:sequence>
> <xs:element name="numPosts" type="xs:integer" minOccurs="0"
> maxOccurs="1"/>
> </xs:sequence>
> <xs:attribute name="firstSubscribed" type="xs:date"
> use="optional"/>
> <xs:attribute name="mailReader" type="xs:string"/>
> </xs:complexType>
> <!-- derived type -->
> <xs:complexType name="RestrictedOne">
> <xs:complexContent>
> <xs:restriction base="BaseInfo">
> <xs:sequence>
> <xs:element name="numPosts" type="xs:integer"
> minOccurs="1"/>
> </xs:sequence>
> <xs:attribute name="firstSubscribed" type="xs:date"
> use="required"/>
> <xs:attribute name="mailReader" type="xs:string"
> fixed="Microsoft Outlook"/>
> </xs:restriction>
> </xs:complexContent>
> </xs:complexType>
> <xs:complexType name="NoBaseRestricted">
> <xs:sequence>
> <xs:element name="numPosts" type="xs:integer" minOccurs="1"/>
> </xs:sequence>
> <xs:attribute name="firstSubscribed" type="xs:date"
> use="required"/>
> <xs:attribute name="mailReader" type="xs:string"
> fixed="Microsoft Outlook"/>
> </xs:complexType>
> </xs:schema>
>
>
> Now if you try:
>
> NoBaseRestricted noBaseRestricted =
> RestrictionFactory.eINSTANCE.createNoBaseRestricted();
> noBaseRestricted.setMailReader("Thunderbird");
> Diagnostician.INSTANCE.validate(noBaseRestricted );
>
>
> Then you get an error as expected because "firstSubscribed" is not set.
>
> However if you do the following:
>
> RestrictedOne restrictedOne =
> RestrictionFactory.eINSTANCE.createRestrictedOne();
> restrictedOne.setMailReader("Thunderbird");
> Diagnostician.INSTANCE.validate(restrictedOne);
>
>
> Then there is no failure on the validation as would be expected. (It
> should fail as firstSubscribed is still not set)
>
> Is this a know issue for EMF?
Yes. There's support to address it in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=51210 but there never
seems enough time for that.
>
> Thanks
> Rob
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Restriction Of Complex Types Not Validating [message #629680 is a reply to message #629514] Wed, 29 September 2010 08:49 Go to previous message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
Thanks for the confirmation Ed, it seems that 51210 is a pretty far reaching issue - I've seen that refered to before as the root cause of a seperate issue.

Thanks

Rob
Previous Topic:How to filter out GMF references
Next Topic:[EMF] FeatureMap with EOpposites
Goto Forum:
  


Current Time: Tue Apr 23 11:54:04 GMT 2024

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

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

Back to the top