[xhtml]

Basic ComplexType Derivation and Substitution Groups

R. Alexander Milowski

milowski at sims.berkeley.edu

#1

Complex Type Definitions - Re-useable Types

#2

Complex Type Derivation

#3

"Valid against the Super Type"

#4

Extensions and Restrictions

#5

Example

#6

Example - Extension vs. Restriction

#7

Simple Type Extension to a Complex Type

#8

Complex Type Extension - Adding Attributes

#9

Complex Type Extension - Adding Elements

#10

Complex Type Extension - Adding Elements/Attributes

#11

What Happens to the Instance?

#12

The Teacher/Parents/Students Example

#13

Making the Content Work with xsi:type

#14

xsi:type Wholly Unsatisfactory

#15

The Solution is Substitution Groups

#16

The Mechanism of Substitution Groups

#17

Generalized Substitutions

#18

Example - XHTML Blocks and Inlines

#19

Example - Extending XHTML

#20

Abstract Elements

#21

Substitution vs. xsi:type

#22

Demo: My Slides

#23

Restricting Complex Types

#24

Restricting Complex Types - Example #1

In restrictions, you repeat the content model with the restrictions in place. Here we have several optional parts:

<xs:complexType name="Product">
   <xs:sequence>
      <xs:element name="number" type="xs:string"/>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="size" type="my:Size" minOccurs="0"/>
      <xs:element name="color" type="my:Colors" minOccurs="0"/>
   </xs:sequence>
</xs:complexType>

Then we can restrict content to be products with a size element:

<!-- Forced to have a size -->
<xs:complexType name="ProductWithSize">
   <xs:complexContent>
   <xs:restriction base="my:Product">
   <xs:sequence>
      <xs:element name="number" type="xs:string"/>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="size" type="my:Size"/>
      <xs:element name="color" type="my:Colors" minOccurs="0"/>
   </xs:sequence>
   </xs:restriction>
   </xs:complexContent>
</xs:complexType>

#25

Restricting Complex Types - Example #2

We can also remove optional parts completely:

<xs:complexType name="Product">
   <xs:sequence>
      <xs:element name="number" type="xs:string"/>
      <xs:element name="name" type="xs:string"/>
      <xs:element name="size" type="my:Size" minOccurs="0"/>
      <xs:element name="color" type="my:Colors" minOccurs="0"/>
   </xs:sequence>
</xs:complexType>

Here we restrict the product to the mimimal required parts:

<xs:complexType name="MinimalProduct">
   <xs:complexContent>
   <xs:restriction base="my:Product">
   <xs:sequence>
      <xs:element name="number" type="xs:string"/>
      <xs:element name="name" type="xs:string"/>
   </xs:sequence>
   </xs:restriction>
   </xs:complexContent>
</xs:complexType>

#26

Example: Biodiversity Data - Requirements

#27

Example: Biodiversity Data - Using Substitution

#28

Example: Biodiversity Data - The Twist

#29

Example: Biodiversity Data - The Substitution Group Solution

#30

Example: Biodiversity Data - Why this solution?

#31

Demo: Mathdoc Schemas