The XML Schema specification supports the ability to derive complex types by extension.
In the XML instance document, you declare the type of an XML element from a set of types that are all derived from the same base type, rather than explicitly declaring the type for the XML element in the XML Schema. The type for the element is defined using the type attribute as shown by the following example XML instance document:
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns="http://shapesrus.com/example" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:type="circle"> <color xmlns="">blue</color> <diameter xmlns="">10</diameter> </shape>
In the preceding XML instance document, the <shape> element is declared as a circle type. The <shape> element in the XML instance document can also be defined as a rectangle type as defined in the following example XML instance document:
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns="http://shapesrus.com/example" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:type="rectangle"> <color xmlns="">blue</color> <length xmlns="">5</length> <width xmlns="">8</width> </shape>In this example, the <shape> element is based on one of the derived types of shapeType base type. The derived types of shapeType are named circle and rectangle, as shown in the following example XML Schema:
In the example XML Schema shown above, the base type called <shapeType> is defined as abstract. An abstract base type cannot be used in the XML instance document to define the type for the element - one of the derived types must be specified instead. In this example, the <shape> element in the XML instance document cannot be declared as shapeType, it must be declared as one of the derived types; either circle or rectangle.
<xsd:complexType name="shapeType"> <xsd:sequence> <xsd:element name="color" type="xsd:string"/> </xsd:sequence> </xsd:complexType>A WSDL is a specific XML Schema that defines a Web Service. Using type substitution with a WSDL is also supported.
You can specify the substitution type for an expanded occurrence of a recurring destination node. This type substitution of an expanded occurrence is only supported for the recurring destination nodes. Destination nodes are located on the right side of mapping panes.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://shapesrus.com/example" xmlns:sru="http://shapesrus.com/example"> <xsd:element name="shape" type="sru:shapeType"/> <xsd:complexType name="shapeType" abstract="true"> <xsd:sequence> <xsd:element name="color" type="xsd:string"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="circle"> <xsd:complexContent> <xsd:extension base="sru:shapeType"> <xsd:sequence> <xsd:element name="diameter" type="xsd:integer"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> <xsd:complexType name="rectangle"> <xsd:complexContent> <xsd:extension base="sru:shapeType"> <xsd:sequence> <xsd:element name="length" type="xsd:integer"/> <xsd:element name="width" type="xsd:integer"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType> </xsd:schema>