Example 4: Transforming a complex element to a table

In the example, the element StockMarket is of complex type and its property Is Multiple is true according to the value of maxOccurs in the XSD file which is 10, so StockMarket will be transformed to a table, named StockMarket and its sub-elements such as: Date, Open, High, Low, Close, Volume and ID will all be transformed to columns of the table automatically.

The following is a segment of an XSD file:

<xs:element name="StockMarket">
  <xs:complexType> 
    <xs:choice maxOccurs="10">
      <xs:element name="Date" type="xs:date" />
      <xs:element name="Open" type="xs:double" />
      <xs:element name="High" type="xs:double" />
      <xs:element name="Low" type="xs:double" />
      <xs:element name="Close" type="xs:double" />
      <xs:element name="Volume" type="xs:double" />
      <xs:element name="ID" type="xs:long" />
    </xs:choice>
  </xs:complexType>
</xs:element>

The following is a segment of a corresponding XML file:

<StockMarket>
  <Date>1999-02-11</Date>
  <Open>11.5</Open>
  <High>12.4375</High>
  <Low>11.5</Low>
  <Close>12.4375</Close>
  <Volume>26600</Volume>
  <id>284</id>
</StockMarket>

The following table named StockMarket is the transformed result:

In the result table, these two columns NodePrimaryKey and NodeForeignKey are generated by system automatically in the transformation process and the columns- id, Date, Open, Low, Close, Volume are transformed from sub-elements of the complex element StockMarket.