Skip to main content
Skip table of contents

Working with derived types

When a complex type in an output/input structure has derived types, either by extension or restriction, the user can choose a derived type and the mappings can be defined using elements of selected derived type.

This is explained with an example. Sample schema used is as provided below:

Sample Schema with derived types

CODE
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.books.org" targetNamespace="http://www.books.org" elementFormDefault="qualified">
   <xsd:complexType name="Publication">
      <xsd:sequence>
         <xsd:element name="Title" type="xsd:string" />
         <xsd:element name="Author" type="xsd:string" />
         <xsd:element name="date" type="xsd:gYear" />
      </xsd:sequence>
   </xsd:complexType>
   <xsd:element name="SamplePublication" type="Publication" />
   <xsd:complexType name="BookPublication">
      <xsd:complexContent>
         <xsd:extension base="Publication">
            <xsd:sequence>
               <xsd:element name="ISBN" type="xsd:string" />
               <xsd:element name="Publisher" type="xsd:string" />
            </xsd:sequence>
         </xsd:extension>
      </xsd:complexContent>
   </xsd:complexType>
   <xsd:complexType name="PaperPublication">
      <xsd:complexContent>
         <xsd:restriction base="Publication">
            <xsd:sequence>
               <xsd:element name="Date" type="xsd:gYear" />
               <xsd:element name="Location" type="xsd:string" />
            </xsd:sequence>
         </xsd:restriction>
      </xsd:complexContent>
   </xsd:complexType>
</xsd:schema>

The schema provided above contains an element SamplePublication of type Publication. The type Publication has two derived types: BookPublication (extension) and PaperPublication (restriction). When the schema is loaded in Mapper, the element SamplePublication is shown in Mapper.


Figure 1: Sample Publication with default type

Since the type Publication has derived types, user can change the type of the element SamplePublication. All the derived types will be shown when right-clicked on the SamplePublication element and the user can select the required derived type as shown in the figure below.


Figure 2: Available derived types

When a different type is selected, the structure will be refreshed to show the selected type.


Figure 3: SamplePublication element when BookPublication type is chosen

Mappings can be defined assuming that the element SamplePublication is of BookPublication type.

When derived types are used, the input/output must comply with the type used.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.