Declaring Mixed Content

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
  <xsd:element name="SONG" type="SongType"/>

  <xsd:complexType name="NarrativeType" mixed="true">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="PERSON"    type="xsd:string" />
      <xsd:element name="ARTIST"    type="xsd:string" />
      <xsd:element name="IRONIC"    type="xsd:string" />
      <xsd:element name="METAPHOR"  type="xsd:string" />
      <xsd:element name="OPINION"   type="NarrativeType" />
    </xsd:choice>
  </xsd:complexType>

  <xsd:complexType name="PersonType">
    <xsd:sequence>
      <xsd:element name="NAME">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="GIVEN"  type="xsd:string"/>
            <xsd:element name="FAMILY" type="xsd:string"/>
           </xsd:sequence>      
         </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="SongType">
    <xsd:sequence>
      <xsd:element name="TITLE"     type="xsd:string"/>
      <xsd:element name="PHOTO"     type="PhotoType"  
        minOccurs="0"/>
      <xsd:element name="COMPOSER"  type="PersonType" 
        maxOccurs="unbounded"/>
      <xsd:element name="PRODUCER"  type="PersonType" 
        minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element name="PUBLISHER" type="xsd:string" 
        minOccurs="0"/>
      <xsd:element name="YEAR"   type="xsd:gYear"/>
      <xsd:element name="ARTIST" type="xsd:string" 
        maxOccurs="unbounded"/>
      <xsd:element name="DESCRIPTION" type="NarrativeType" 
        minOccurs="0"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="PhotoType">
    <xsd:complexContent>
       <xsd:restriction base="xsd:anyType">
         <xsd:attribute name="ALT"    type="xsd:string"/>
         <xsd:attribute name="WIDTH"  type="xsd:positiveInteger"/>
         <xsd:attribute name="HEIGHT" type="xsd:positiveInteger"/> 
      </xsd:restriction>
    </xsd:complexContent>
  </xsd:complexType>
  
</xsd:schema>

Previous | Next | Top | Cafe con Leche

Copyright 2000-2003, 2006 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified January 3, 2006