TOC PREV NEXT INDEX


Extensions


The only purpose of simple content extensions is to add attributes to an existing base type. In this case, a C struct is generated containing a base element (base) of the type being extended and attribute elements for the additional attributes. For C++, the attributes are added to the derived class.
The general mapping is as follows:
XSD type:
<xsd:complexType name="TypeName">
 
   <xsd:simpleContent>
 
      <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:simpleContent>
 
</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, BaseType can only be a built-in XSD simple type or a type that references a simple type.

Objective Systems, Inc.

102 Pickering Way, Suite #506
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com
TOC PREV NEXT INDEX