XML/XML Schema/Useful Simple Type

Материал из Web эксперт
Версия от 08:26, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

British postal codes

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:simpleType name="gbr_Postcode" >
       <xs:restriction base="xs:string" > 
          <xs:pattern value="(([A-Z]{2}[0-9]{2})|([A-Z][0-9])|
                      ([A-Z][0-9]{2})|([A-Z]{2}[0-9])) ([0-9][A-Z]{2})"/>
       </xs:restriction>
    </xs:simpleType>
</xs:schema>



Canadian addresses require the name of a province, plus a postal code

File: Schema.xsd
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexType name="Address">
    <xs:sequence>
      <xs:element name="Name" type="xs:string" />
      <xs:element name="Street" type="xs:string" minOccurs="1"
        maxOccurs="3" />
      <xs:element name="City" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="MailAddress" type="Address" />
  <xs:element name="BillAddress" type="Address" />
  <xs:simpleType name="CAN_PostalCode">
    <xs:restriction base="xs:string">
      <xs:pattern
        value="[A-Z]{1}[0-9]{1}[A-Z]{1} [0-9]{1}[A-Z]{1}[0-9]{1}" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="CAN_Address">
    <xs:complexContent>
      <xs:extension base="Address">
        <xs:sequence>
          <xs:element name="Province" type="xs:string" />
          <xs:element name="PostalCode" type="CAN_PostalCode" />
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>
File: Data.xml
<?xml version="1.0" ?>
<MailAddress xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:noNamespaceSchemaLocation="Schema.xsd"
         xsi:type="CAN_Address">
   <Name>name</Name>
   <Street>8185 Way</Street>
   <City>Vancouver</City>
   <Province>BC</Province>
   <PostalCode>A1A 1A1</PostalCode>
</MailAddress>



Canadian postal codes are two fixed-length (3-character) codes separated by a single space

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:simpleType name="can_PostalCode" > <!-- "xnx nxn" -->
       <xs:restriction base="xs:string" >
          <xs:length value="7" />   <!-- 6 alphanumeric chars + 1 space -->
          <xs:pattern value="[A-Z][0-9][A-Z] [0-9][A-Z][0-9]" />
       </xs:restriction>
    </xs:simpleType>
</xs:schema>



Constrain our dotted-quad to use 3-digit numbers in the range 0 to 255

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
  <xs:simpleType name="ipv4_Address">
    <xs:restriction base="xs:string">
      <xs:pattern
        value="(([0-9]{1,2} | [1][0-9]{2} | [2][0-4][0-9] | [2][5][0-5])\.){3}
                 ([0-9]{1,2} | [1][0-9]{2} | [2][0-4][0-9] | [2][5][0-5])" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>



Define xml schema for a styled letter

File: Data.xml
<?xml version="1.0"?>
<letter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="Schema.xsd">
  <greeting><hello/> Bob!</greeting>
  <body>
    text
    <item/> 
    text
    <price/>
    text
    text
    <arrivalDate/>.
  </body>
  <closing>Just closing.<lax/></closing>
</letter>
File: Schema.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="letter">
    <xsd:complexType mixed="true">
      <xsd:sequence>
        <xsd:element name="greeting">
          <xsd:complexType mixed="true">
            <xsd:choice>
              <xsd:element name="hello"/>
              <xsd:element name="hi"/>
              <xsd:element name="dear"/>
            </xsd:choice>
          </xsd:complexType>
        </xsd:element>
        <xsd:element name="body">
          <xsd:complexType mixed="true">
            <xsd:all>
              <xsd:element name="item"/>
              <xsd:element name="price"/>
              <xsd:element name="arrivalDate"/>
            </xsd:all>
          </xsd:complexType>
        </xsd:element>
        <xsd:element name="closing">
          <xsd:complexType mixed="true">
            <xsd:complexContent>
              <xsd:restriction base="xsd:anyType">
                <xsd:sequence>
                  <xsd:any processContents="lax"/>
                </xsd:sequence>
              </xsd:restriction>
            </xsd:complexContent>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>



Domain Names

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:simpleType name="ip_DomainName">
       <xs:restriction base="xs:string">
          <xs:pattern value="((([A-Za-z0-9])|([A-Za-z0-9][A-Za-z0-9\-]*
                      [A-Za-z0-9]))\.)+(com|edu|gov|mil|net|org)" />
       </xs:restriction>
    </xs:simpleType>
</xs:schema>



extended datatype for the US addresses:

File:  Schema.xsd
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexType name="Address">
    <xs:sequence>
      <xs:element name="Name" type="xs:string" />
      <xs:element name="Street" type="xs:string" minOccurs="1"
        maxOccurs="3" />
      <xs:element name="City" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="MailAddress" type="Address" />
  <xs:element name="BillAddress" type="Address" />
  <xs:simpleType name="USPS_StateCode">
    <xs:restriction base="xs:string">
      <xs:enumeration value="AL" /><!-- Alabama -->
      <xs:enumeration value="AK" /><!-- Alaska -->
      <xs:enumeration value="WY" /><!-- Wyoming -->
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="USPS_ZIP">
    <xs:restriction base="xs:integer">
      <xs:minInclusive value="01000" />
      <xs:maxInclusive value="99999" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="USA_Address">
    <xs:complexContent>
      <xs:extension base="Address">
        <xs:sequence>
          <xs:element name="State" type="USPS_StateCode" />
          <xs:element name="ZIP" type="USPS_ZIP" />
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>
File: Address.xsml 
<?xml version="1.0" ?>
<MailAddress xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:noNamespaceSchemaLocation="Schema.xsd"
         xsi:type="USA_Address">
   <Name>name</Name>
   <Street>123 St.</Street>
   <City>LA</City>
   <State>AL</State>
   <ZIP>11111</ZIP>
</MailAddress>



Five-digit ZIP codes

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:simpleType name="usa_ZIP">   <!-- "nnnnn" or "nnnnn-nnnn" -->
      <xs:restriction base="xs:positiveInteger">
         <xs:pattern value="[0-9]{5}(-[0-9]{4})?" />
      </xs:restriction>
    </xs:simpleType>
</xs:schema>



Gender code based on xs:nonNegativeInteger

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:simpleType name="realworld_GenderCode">
       <xs:restriction base="xs:nonNegativeInteger">
          <xs:enumeration value="0" /> <!-- Not Known -->
          <xs:enumeration value="1" /> <!-- Male -->
          <xs:enumeration value="2" /> <!-- Female -->
          <xs:enumeration value="3" /> <!-- Male-to-Female Transsexual -->
          <xs:enumeration value="4" /> <!-- Female-to-Male Transsexual -->
          <xs:enumeration value="5" /> <!-- True Neuter -->
          <xs:enumeration value="9" /> <!-- Not Specified -->
       </xs:restriction>
    </xs:simpleType>
</xs:schema>



IP Addresses

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
  <xs:simpleType name="dottedQuad">
    <xs:restriction base="xs:string">
      <xs:pattern value="([0-9]*\.){3}[0-9]*" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>



IPv6 addresses are easier to describe using a simple regex

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:simpleType name="ipv6_Address">
       <xs:restriction base="xs:string">
          <xs:pattern value="([A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}" />
       </xs:restriction>
    </xs:simpleType>
</xs:schema>



Mexican postal codes are simple five-digit numbers, with the first two digits representing a region, followed by three digits for zone and locality

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:simpleType name="mex_PostalCode" > <!-- "nnnnn" -->
       <xs:restriction base="xs:positiveInteger" >
          <xs:length value="5" />
       </xs:restriction>
    </xs:simpleType>
</xs:schema>



Ocean states

<?xml version="1.0" ?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:simpleType name="oceanState">
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="CA"/>
        <xsd:enumeration value="OR"/>
        <xsd:enumeration value="WA"/>
        <xsd:enumeration value="ME"/>
        <xsd:enumeration value="NH"/>
        <xsd:enumeration value="MA"/>
        <xsd:enumeration value="RI"/>
        <xsd:enumeration value="CT"/>
        <xsd:enumeration value="NY"/>
        <xsd:enumeration value="NJ"/>
        <xsd:enumeration value="DE"/>
        <xsd:enumeration value="MD"/>
        <xsd:enumeration value="VA"/>
        <xsd:enumeration value="NC"/>
        <xsd:enumeration value="SC"/>
        <xsd:enumeration value="GA"/>
        <xsd:enumeration value="FL"/>
      </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>



Our addresses in Great Britain

File: Schema.xsd
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexType name="Address">
    <xs:sequence>
      <xs:element name="Name" type="xs:string" />
      <xs:element name="Street" type="xs:string" minOccurs="1"
        maxOccurs="3" />
      <xs:element name="City" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="MailAddress" type="Address" />
  <xs:element name="BillAddress" type="Address" />
  <xs:simpleType name="GBR_Postcode">
    <xs:restriction base="xs:string">
      <xs:pattern
        value="(([A-Z]{2}[0-9]{2})|([A-Z]{2}[0-9][A-Z])
                                  |([A-Z][0-9]{2})) ([0-9][A-Z]{2})" />
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="GBR_Address">
    <xs:complexContent>
      <xs:extension base="Address">
        <xs:sequence>
          <xs:element name="County" type="xs:string"
            minOccurs="0" />
          <xs:element name="Postcode" type="GBR_Postcode" />
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>

File: Data.xml
<?xml version="1.0" ?>
<MailAddress xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:noNamespaceSchemaLocation="Schema.xsd"
         xsi:type="GBR_Address">
   <Name>name</Name>
   <Street>street</Street>
   <Street>1102 Road</Street>
   <City>city</City>
   <Postcode>B27 6BH</Postcode>
</MailAddress>



Schema for address

File: Data.xml
<?xml version="1.0"?>
<addr:address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.wbex.ru 
      Schema.xsd"
    xmlns:addr="http://www.wbex.ru"
    addr:language="en"
    addr:ssn="123-45-6789">
  <fullName>
    <first>first</first>
    <middle>middle</middle>
    <last>last</last>
  </fullName>
  <contacts>
    <phone addr:location="home" addr:number="111.222.3333"/>
  </contacts>
</addr:address>
File: Schema.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru"
  xmlns:addr="http://www.wbex.ru"
  attributeFormDefault="qualified">
 <xsd:element name="address">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="fullName">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="first" type="addr:nameComponent"/>
            <xsd:element name="middle" type="addr:nameList"
                minOccurs="0"/>
            <xsd:element name="last" type="addr:nameComponent"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="contacts" type="addr:contactsType" minOccurs="0"/>
      <xsd:element name="notes" minOccurs="0">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:any namespace="http://www.w3.org/1999/xhtml"
                 minOccurs="0" maxOccurs="unbounded"
                 processContents="skip"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  <xsd:attributeGroup ref="addr:nationality"/>
  <xsd:attribute name="ssn" type="addr:ssn"/>
  <xsd:anyAttribute namespace="http://www.w3.org/1999/xlink"
      processContents="skip"/>
  </xsd:complexType>
 </xsd:element>
 
 <xsd:complexType name="nameComponent">
  <xsd:simpleContent>
    <xsd:extension base="addr:nameString"/>
  </xsd:simpleContent>
 </xsd:complexType>
 <xsd:complexType name="nameList">
  <xsd:simpleContent>
    <xsd:extension base="addr:nameListType"/>
  </xsd:simpleContent>
 </xsd:complexType>
 
 <xsd:simpleType name="nameListType">
  <xsd:list itemType="addr:nameString"/>
 </xsd:simpleType>
 
 <xsd:simpleType name="nameString">
  <xsd:restriction base="xsd:string">
    <xsd:maxLength value="50"/>
  </xsd:restriction>
 </xsd:simpleType>
 
 <xsd:simpleType name="ssn">
  <xsd:restriction base="xsd:string">
    <xsd:pattern value="\d\d\d-\d\d-\d\d\d\d"/>
  </xsd:restriction>
 </xsd:simpleType>
 
  <xsd:complexType name="contactsType">
    <xsd:sequence>
      <xsd:element name="phone" minOccurs="0">
        <xsd:complexType>
          <xsd:complexContent>
            <xsd:restriction base="xsd:anyType">
              <xsd:attribute name="location">
                <xsd:simpleType>
                  <xsd:union memberTypes="addr:locationType xsd:NMTOKEN"/>
                </xsd:simpleType>
              </xsd:attribute>
              <xsd:attribute name="number" type="xsd:string"/>
            </xsd:restriction>
          </xsd:complexContent>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:simpleType name="locationType">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="work"/>
      <xsd:enumeration value="home"/>
      <xsd:enumeration value="mobile"/>
    </xsd:restriction>      
  </xsd:simpleType>
  
 <xsd:attributeGroup name="nationality">
  <xsd:attribute name="language" type="xsd:language"/>
 </xsd:attributeGroup>
</xsd:schema>



Simple type for length Units

<?xml version="1.0" ?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:simpleType name="lengthUnits">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="angstrom"/> 
            <xsd:enumeration value="nm"/> 
            <xsd:enumeration value="mm"/> 
            <xsd:enumeration value="cm"/> 
            <xsd:enumeration value="dm"/> 
            <xsd:enumeration value="m"/> 
            <xsd:enumeration value="km"/> 
            <xsd:enumeration value="ym"/> 
            <xsd:enumeration value="mil"/> 
            <xsd:enumeration value="inch"/> 
            <xsd:enumeration value="in"/> 
            <xsd:enumeration value="feet"/> 
            <xsd:enumeration value="ft"/> 
            <xsd:enumeration value="yard"/> 
            <xsd:enumeration value="yd"/> 
        </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>



Simple type for temperature

<?xml version="1.0" ?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:simpleType name="temperatureUnits">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="celsius"/> 
            <xsd:enumeration value="farenheit"/>
            <xsd:enumeration value="kelvin" />  
        </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>



Simple type for weight unit

<?xml version="1.0" ?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:simpleType name="weightUnits">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="gram"/> 
            <xsd:enumeration value="kilogram"/> 
            <xsd:enumeration value="kg"/>  
            <xsd:enumeration value="ounce"/>
            <xsd:enumeration value="pound"/>
            <xsd:enumeration value="lb"/>  
            <xsd:enumeration value="ton"/>    
            <xsd:enumeration value="grain"/> 
            <xsd:enumeration value="scruple"/>  
            <xsd:enumeration value="carat"/>  
            <xsd:enumeration value="pennyweight"/>   
            <xsd:enumeration value="dram"/>  
            <xsd:enumeration value="stone"/> 
            <xsd:enumeration value="quarter"/> 
            <xsd:enumeration value="slug"/>   
            <xsd:enumeration value="metric ton"/>  
            <xsd:enumeration value="tonne"/> 
            <xsd:enumeration value="long ton"/>    
        </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>



SSN type with pattern

File: Data.xml
<?xml version="1.0"?>
<addr:address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.wbex.ru 
      Schema.xsd"
    xmlns:addr="http://www.wbex.ru"
    addr:language="en"
    addr:ssn="123-45-6789">
  <fullName>
    <first>first</first>
    <middle>middlecott</middle>
    <last>last</last>
  </fullName>
  <contacts>
    <phone addr:location="home" addr:number="111.222.3333"/>
  </contacts>
</addr:address>
File: Schema.xsd
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru"
  xmlns:addr="http://www.wbex.ru"
  attributeFormDefault="qualified">
 <xsd:element name="address">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="fullName">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="first" type="addr:nameComponent"/>
            <xsd:element name="middle" type="addr:nameComponent" minOccurs="0"/>
            <xsd:element name="last" type="addr:nameComponent"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="contacts" type="addr:contactsType" minOccurs="0"/>
    </xsd:sequence>
  <xsd:attributeGroup ref="addr:nationality"/>
  <xsd:attribute name="ssn" type="addr:ssn"/>
  </xsd:complexType>
 </xsd:element>
 
 <xsd:complexType name="nameComponent">
  <xsd:simpleContent>
    <xsd:extension base="addr:nameString"/>
  </xsd:simpleContent>
 </xsd:complexType>
 
 <xsd:simpleType name="nameString">
  <xsd:restriction base="xsd:string">
    <xsd:maxLength value="50"/>
  </xsd:restriction>
 </xsd:simpleType>
 
 <xsd:simpleType name="ssn">
  <xsd:restriction base="xsd:string">
    <xsd:pattern value="\d\d\d-\d\d-\d\d\d\d"/>
  </xsd:restriction>
 </xsd:simpleType>
 
  <xsd:complexType name="contactsType">
    <xsd:sequence>
      <xsd:element name="phone" minOccurs="0">
        <xsd:complexType>
          <xsd:complexContent>
            <xsd:restriction base="xsd:anyType">
              <xsd:attribute name="location" type="addr:locationType"/>
              <xsd:attribute name="number" type="xsd:string"/>
            </xsd:restriction>
          </xsd:complexContent>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:simpleType name="locationType">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="work"/>
      <xsd:enumeration value="home"/>
      <xsd:enumeration value="mobile"/>
    </xsd:restriction>      
  </xsd:simpleType>
  
 <xsd:attributeGroup name="nationality">
  <xsd:attribute name="language" type="xsd:language"/>
 </xsd:attributeGroup>
</xsd:schema>



telephone numbers

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:simpleType name="nanp_GenericPhoneNumber">
       <xs:restriction base="xs:positiveInteger">
          <xs:pattern value="[2-9](([0-9]{6})|([0-9]{9}))" />
       </xs:restriction>
    </xs:simpleType>
    
    <xs:element name="PhoneNumber" type="nanp_GenericPhoneNumber"/>
</xs:schema>

XML data that conforms to this description might look something like this:
<PhoneNumber>3135551212</PhoneNumber>



Uniform Resource Identifiers

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:simpleType name="uri_Scheme">
       <xs:restriction base="xs:string">
          <xs:pattern value="[A-Za-z]([A-Za-z0-9\+\-\.])*" />
       </xs:restriction>
    </xs:simpleType>
</xs:schema>



URI schema

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:simpleType name="uri_Scheme">
       <xs:restriction base="xs:string">
          <xs:enumeration value="ftp" />     
          <xs:enumeration value="http" />    
          <xs:enumeration value="mailto" />  
          <xs:enumeration value="news" />    
          <xs:enumeration value="telnet" />  
          <xs:enumeration value="urn" />     
       </xs:restriction>
    </xs:simpleType>
</xs:schema>



Use simple strings for these various parts of a person"s name

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:element name="PersonName" >
       <xs:complexType>
          <xs:choice>
             <xs:element name="SingleName" type="xs:string" />
             <xs:sequence>
                <xs:element name="Prefix"     type="xs:string" minOccurs="0" />
                <xs:element name="GivenName"  type="xs:string" />
                <xs:element name="MiddleName" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="FamilyName" type="xs:string" />
                <xs:element name="Suffix"     type="xs:string" minOccurs="0" />
             </xs:sequence>
          </xs:choice>
       </xs:complexType>
    </xs:element>
</xs:schema>

Some examples of XML data that conform to this datatype include: 
<PersonName>
   <Prefix>Mr</Prefix>
   <GivenName>J</GivenName>
   <MiddleName>Q</MiddleName>
   <FamilyName>Public</FamilyName>
   <Suffix>Jr</Suffix>
</PersonName>
<PersonName>
   <GivenName>Jane</GivenName>
   <FamilyName>Doe</FamilyName>
</PersonName> 
<PersonName>
   <SingleName>Madonna</SingleName>
</PersonName>



US postal address

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru"
  elementFormDefault="qualified">
    <xs:complexType name="postalAddress">
       <xs:sequence>
          <xs:element name="Street" type="xs:string" maxOccurs="4" />
          <xs:element name="City" type="xs:string" />
          <xs:element name="State" type="xs:string" />
          <xs:element name="ZIP" type="xs:string" />
          <xs:element name="Country" type="xs:string" />
       </xs:sequence>
    </xs:complexType>
    
    <xs:element name="Address" type="postalAddress" />
</xs:schema>



Zip code

<?xml version="1.0" ?> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:simpleType name="zipcode">
      <xsd:restriction base="xsd:string">
        <xsd:pattern value="[0-9]{5}(-[0-9]{4})?"/>
      </xsd:restriction>
    </xsd:simpleType>
</xsd:schema>