23.2. An Example of a Simple Type Mapping to a Database Schema

Listing 23.1 shows the simple type partNameType, first seen in Listing 10.1.

Listing 23.1. A Simple Type Derived from a Token (catalog.xsd)
<xsd:simpleType name="partNameType" 
                final="list,union" 
                id="catalog.partName.sType"> 
    <xsd:annotation> 
        <xsd:documentation xml:lang="en"> 
            A part name can be almost anything. 
            The name is a short description. 
        </xsd:documentation> 
    </xsd:annotation> 
    <xsd:restriction base="xsd:token" 
                     id="pnt-rst"> 
        <xsd:minLength value="1"/> 
        <xsd:maxLength value="40"/> 
    </xsd:restriction> 
</xsd:simpleType> 

Mapping this to a database schema involves creating a database column of type token, entering a description of the column, and enforcing the minLength and maxLength ...

Get XML Schema Complete Reference, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.