Attribute Extension

It is possible to extend a base type to contain additional attributes. In this case, the additional attribute definitions are added to the structure generated for the complexContent type.

The general mapping for complexContent with extension attributes is as follows:

XSD type:

   <xsd:complexType name=”TypeName”>
      <xsd:complexContent>
         <xsd:extension base="BaseType">
            <xsd:attribute name=”attr1” type=”Type1”/>
            <xsd:attribute name=”attr2” type=”Type2”/>
            ...
            <xsd:attribute name=”attrN” type=”TypeN”/>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>

Generated C code:

   typedef struct TypeName {
      BaseType base;

      /* attributes */
      Type1 attr1;
      Type2 attr2;
      ...
      TypeN attrN;
   } TypeName;

Generated C++ code:

   class TypeName : public BaseType {
      /* attributes */
      Type1 attr1;
      Type2 attr2;
      ...
      TypeN attrN;

      ...
   } ;

In this case, the attributes are handled the same as they were in the Attributes section above. If any are optional, an optional bit mask is added at the beginning of the complexContent structure. Logic to handle fixed and default values is added to the initialization and encode/decode functions.