2. Our First Schema (samples)

Sample 1

[download]

<?xml version="1.0"?> 
<!-- $Header: /home/cvsroot/w3c-xml-schema/user/examples/first.xml,v
1.22001/11/01 22:03:06 vdv Exp $ -->
<library>
  <book id="b0836217462" available="true">
    <isbn>
      0836217462
    </isbn>
    <title lang="en">
      Being a Dog Is a Full-Time Job
    </title>
    <author id="CMS">
      <name>
        Charles M Schulz
      </name>
      <born>
        1922-11-26
      </born>
      <dead>
        2000-02-12
      </dead>
    </author>
    <character id="PP">
      <name>
        Peppermint Patty
      </name>
      <born>
        1966-08-22
      </born>
      <qualification>
        bold, brash and tomboyish
      </qualification>
    </character>
    <character id="Snoopy">
      <name>
        Snoopy
      </name>
      <born>
        1950-10-04
      </born>
      <qualification>
        extroverted beagle
      </qualification>
    </character>
    <character id="Schroeder">
      <name>
        Schroeder
      </name>
      <born>
        1951-05-30
      </born>
      <qualification>
        brought classical music to the Peanuts strip
      </qualification>
    </character>
    <character id="Lucy">
      <name>
        Lucy
      </name>
      <born>
        1952-03-03
      </born>
      <qualification>
        bossy, crabby and selfish
      </qualification>
    </character>
  </book>
</library>

Sample 2

.../...
	

  <title lang="en">
    Being a Dog Is a Full-Time Job
  </title>

.../...
	

  <name>
    Charles M Schulz
  </name>

	

  <born>
    1922-11-26
  </born>

.../...


Sample 3


  <library>
    <book id="b0836217462" available="true">
      .../...
    </book>
  </library>


		

  <character id="Lucy">
    <name>
      Lucy
    </name>
    <born>
      1952-03-03
    </born>
    <qualification>
      bossy, crabby and selfish
    </qualification>
  </character>




Sample 4

		

  <author id="CMS">
    <name>
      Charles M Schulz
    </name>
    <born>
      1922-11-26
    </born>
    <dead>
      2000-02-12
    </dead>
  </author>

.../...
		

  <title lang="en">
    Being a Dog Is a Full-Time Job
  </title>




Sample 5

			

  <born>
    1922-11-26
  </born>

.../...
			

  <qualification>
    brought classical music to the Peanuts strip
  </qualification>

.../... 


  <book available="true"/>



Sample 6


  <name>
    Charles M Schulz
  </name>



Sample 7

 

  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="name" type="xs:string"/>
    .../...
  </xs:schema>



Sample 8

 

  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="name" type="xs:string"/>
    <xs:element name="qualification" type="xs:string"/>
    <xs:element name="born" type="xs:date"/>
    <xs:element name="dead" type="xs:date"/>
    <xs:element name="isbn" type="xs:integer"/>
    <xs:attribute name="id" type="xs:ID"/>
    <xs:attribute name="available" type="xs:boolean"/>
    <xs:attribute name="lang" type="xs:language"/>
    .../...
  </xs:schema>



Sample 9

	

  <xs:element name="isbn" type="xs:integer"/>

		
		or
		
	

  <xs:attribute name="isbn" type="xs:integer"/>



Sample 10


  <title lang="en">
    Being a Dog Is a Full-Time Job
  </title>



Sample 11

	

  <xs:element name="title">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute ref="lang"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>



Sample 12

	

  <xs:element name="library">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="book" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>



Sample 13

	

  <xs:element name="author">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="name"/>
        <xs:element ref="born"/>
        <xs:element ref="dead" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute ref="id"/>
    </xs:complexType>
  </xs:element>



Sample 14

[download]

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="name" type="xs:string"/>
  <xs:element name="qualification" type="xs:string"/>
  <xs:element name="born" type="xs:date"/>
  <xs:element name="dead" type="xs:date"/>
  <xs:element name="isbn" type="xs:integer"/>
  <xs:attribute name="id" type="xs:ID"/>
  <xs:attribute name="available" type="xs:boolean"/>
  <xs:attribute name="lang" type="xs:language"/>
  <xs:element name="title">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute ref="lang"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <xs:element name="library">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="book" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="author">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="name"/>
        <xs:element ref="born"/>
        <xs:element ref="dead" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute ref="id"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="book">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="isbn"/>
        <xs:element ref="title"/>
        <xs:element ref="author" minOccurs="0" maxOccurs="unbounded"/> 
        <xs:element ref="character" minOccurs="0"
          maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute ref="id"/>
      <xs:attribute ref="available"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="character">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="name"/>
        <xs:element ref="born"/>
        <xs:element ref="qualification"/>
      </xs:sequence>
      <xs:attribute ref="id"/>
    </xs:complexType>
  </xs:element>
</xs:schema>