The Price Schema

<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
 
  <xsd:element name="SONG" type="SongType"/>

  <xsd:simpleType base="xsd:string" name="money">
    <xsd:pattern value="\p{Sc}\p{Nd}+(\.\p{Nd}\p{Nd})?"/>
    <!-- 
       Regular Expression:
       \p{Sc}             Any Unicode currency indicator; e.g. $, &#xA5, &#xA3, &#A4, etc.
       \p{Nd}             A Unicode decimal digit character
       \p{Nd}+            One or more Unicode decimal digit characters
       \.                 The period character
       (\.\p{Nd}\p{Nd})
       (\.\p{Nd}\p{Nd})?  Zero or one strings of the form .35
       
       This works for any decimalized currency. 
       
    -->
  </xsd:simpleType>

  <xsd:complexType name="SongType">
      <xsd:element name="TITLE"     type="xsd:string" 
        minOccurs="1" maxOccurs="1"/>
      <xsd:element name="PHOTO"     type="PhotoType"  
        minOccurs="0" maxOccurs="1"/>
      <xsd:element name="COMPOSER"  type="PersonType" 
        minOccurs="1" maxOccurs="unbounded"/>
      <xsd:element name="PRODUCER"  type="PersonType" 
        minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element name="PUBLISHER" type="xsd:string" 
        minOccurs="0" maxOccurs="1"/>
      <xsd:element name="YEAR"   type="xsd:year" 
        minOccurs="1" maxOccurs="1"/>
      <xsd:element name="ARTIST" type="xsd:string" 
        minOccurs="1" maxOccurs="unbounded"/>
      <xsd:element name="PRICE" type="money" 
        minOccurs="1" maxOccurs="1"/>      
      
  </xsd:complexType>

  <xsd:complexType name="PersonType">
    <xsd:element name="NAME">
      <xsd:complexType>
        <xsd:all>
          <xsd:element name="GIVEN"  type="xsd:string" 
            minOccurs="1" maxOccurs="1"/>
          <xsd:element name="FAMILY" type="xsd:string" 
            minOccurs="1" maxOccurs="1"/> 
        </xsd:all>     
      </xsd:complexType>
    </xsd:element>
  </xsd:complexType>

  <xsd:complexType name="PhotoType">
    <xsd:complexContent>
       <xsd:restriction base="xsd:anyType">
         <xsd:attribute name="ALT"    type="xsd:string"/>
         <xsd:attribute name="WIDTH"  type="xsd:nonNegativeInteger"/>
         <xsd:attribute name="HEIGHT" type="xsd:nonNegativeInteger"/> 
      </xsd:restriction>
    </xsd:complexContent>
  </xsd:complexType>
  
</xsd:schema>

Previous | Next | Top | Cafe con Leche

Copyright 2000 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified September 30, 2000