Restrictions

It is possible to restrict elements and attributes in an existing content model group by using the restriction element. For either elements or attributes, it is possible to exclude optional items from the derived content model. It is also possible to restrict wildcards (any or anyAttribute) to contain values of a given type. It is also possible to further restrict facets such as minOccurs and maxOccurs to specify a narrower range than was defined in the base type.

As of XBinder version 1.2, restricted types are handled by generating a completely new type definition containing only the restricted items. In previous versions, the generated type contained only a single base element that referenced the base type.

As of XBinder 1.4, the restricted type is now included in the generated derivations type for the items. This makes it possible to successfully decode an item that referecnes the base type and uses an xsi:type attribute to select the restricted type for substitution.

The general mapping is as follows:

XSD type:

   <xsd:complexType name="TypeName">
      <xsd:complexContent>
         <xsd:restriction base="BaseType">
         ...
         </xsd:restriction>
      </xsd:complexContent>
   </xsd:complexType>

Generated C code:

   typedef struct TypeName {
      restricted elements/attributes from BaseType
   } TypeName;

Generated C++ code:

   class TypeName : public OSRTBaseType {
      restricted elements/attributes from BaseType
   } ;