10.1. An Example of a Simple Type Derived from the Built-in token Datatype

The simpleType element restricts the value of another simple type. Listing 10.1 demonstrates the XML representation of partNameType. A part name represents a short description of a part. The name is limited to 40 characters, perhaps due to database or screen real estate limitations.

Listing 10.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> 

An element type whose structure type is partNameType might look like the following element:

<xsd:element name="partName" type="partNameType"/> 

Given the preceding element type, the following element is valid in an XML instance:

<partName>Short Description of Unit 1</partName> 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.233.41