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.

Copyright © Objective Systems 2002-2008
This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included.

Objective Systems, Inc.

55 Dowlin Forge Road
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