XML Tutorial/XML Schema/schemaLocation

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

One xml document with two xml schemas

   <source lang="xml">

File: Data.xml <?xml version="1.0"?>

   <sensor>gamma</sensor>

File: data.xsd <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"

           targetNamespace="http://www.demo2s.ru"
           xmlns="http://www.demo2s.ru"
           xmlns:t="http://www.wbex.ru"
           elementFormDefault="qualified">
   <xsd:element name="data">
       <xsd:complexType>
           <xsd:sequence>
               <xsd:element name="sensor" type="t:sensor_type"/>
           </xsd:sequence>
       </xsd:complexType>
   </xsd:element>

</xsd:schema>

File: sensor.xsd <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"

           targetNamespace="http://www.wbex.ru"
           xmlns="http://www.wbex.ru"
           elementFormDefault="qualified">
   <xsd:simpleType name="sensor_type">
      <xsd:restriction base="xsd:string">
          <xsd:enumeration value="alpha"/>
          <xsd:enumeration value="beta"/>
      </xsd:restriction>
   </xsd:simpleType>

</xsd:schema></source>