Restriction Of Complex Types Not Validating [message #629514] |
Tue, 28 September 2010 10:39  |
Eclipse User |
|
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.23798 seconds