Book HomeXML SchemaSearch this book

A.6. W3C XML Schema

As we have seen, the W3C XML Schema is a strongly typed schema language that eliminates any nondeterministic design from the described markup to insure that there is no ambiguity in the determination of the datatypes, and that the validation can be performed by a finite state machine. Table A-2 provides the fact sheet for W3C XML Schema.

Table A-2. W3C XML Schema fact sheet

Author:

W3C.

Status:

Recommendation.

Location:

http://www.w3.org/TR/xmlschema-0.

Type:

object-oriented

PSVI:

Yes.

Structures:

Yes.

Datatypes:

Yes.

Integrity:

Yes (internal through ID/IDREF/IDREFS and xs:unique/xs:key/xs:keyref).

Rules:

No.

Vendor support:

Potentially excellent but currently still immature.

Miscellaneous:

Borrows many ideas from OOP design; considered complex; requires deterministic content models; part of the foundation of XML in the vision of the W3C.

A.6.1. Example

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="library">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="book" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="isbn" type="xs:string"/>
              <xs:element name="title" type="xs:string"/> 
              <xs:element name="author-ref" minOccurs="0"
                maxOccurs="unbounded">
               <xs:complexType> 
               <xs:attribute name="id" type="xs:IDREF"
                 use="required"/>
               </xs:complexType>
              </xs:element> 
              <xs:element name="character-ref" minOccurs="0"
                maxOccurs="unbounded">
               <xs:complexType> 
               <xs:attribute name="id" type="xs:IDREF"
                 use="required"/>
               </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="id" type="xs:ID" use="required"/>
          </xs:complexType>
        </xs:element> 
        <xs:element name="author" minOccurs="0"
          maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="name"/>
              <xs:element name="nickName" type="xs:string"/>
              <xs:element name="born" type="xs:string"/>
              <xs:element name="dead" type="xs:string"/>
            </xs:sequence>
            <xs:attribute name="id" type="xs:ID" use="required"/>
          </xs:complexType>
        </xs:element> 
        <xs:element name="character" minOccurs="0"
          maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element ref="name"/>
              <xs:element name="since" type="xs:string"/>
              <xs:element name="qualification" type="xs:string"/>
            </xs:sequence>
            <xs:attribute name="id" type="xs:ID" use="required"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="name" type="xs:string"/>
</xs:schema>


Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.