untitled

(ff) #1
2.5 Exercises 49

For example, suppose that it is possible for thedateCreatedattribute to be
not applicable to a citation. Simply omitting this attribute would mean that
it has a value which is unknown rather than that the attribute does not apply
to the citation. To allow for such special cases, one can add additional values
to a datatype by using aunionas follows:

<element name=’DateCreated’>
<simpleType>
<xsd:union memberTypes=’xsd:date’>
<xsd:simpleType>
<enumeration value=’N/A’/>
</xsd:simpleType>
</xsd:union>
</simpleType>
</element>

Summary



  • XSD provides built-in datatypes for the most commonly used purposes,
    such as strings, numbers, dates, times, and resource references (URIs).

  • New datatypes can be defined by restricting another datatype, combining
    several datatypes (union), or allowing a sequence of values (list).


2.5 Exercises



  1. Convert the molecule DTD shown in figure 1.6 to an XML schema.

  2. Revise the molecule schema in exercise 2.1 above so that theelementType
    attribute can only be one of the standard abbreviations of the 118 currently
    known elements in the periodic table.

  3. Define a simple datatype for a single DNA base. Hint: Use an enumera-
    tion as in exercise 2.2 above.

  4. Define a simple datatype for a DNA sequence.

  5. Define a more realistic datatype for a DNA sequence. It is a common
    practice to break up amino acid and DNA sequences into more manage-
    able pieces. For example, the following is a sequence in the European
    Molecular Biology Laboratory (EMBL) database:

Free download pdf