XML/XML Schema/xlink — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 11:26, 26 мая 2010

attribute with referencing xlink

   <source lang="xml">

File: Data.xml <?xml version="1.0"?> <Mission xmlns="http://www.wbex.ru/unit/mission"

        xmlns:xlink="http://www.w3.org/1999/xlink/namespace"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation=
                  "http://www.wbex.ru/unit/mission
                   Schema.xsd">
   <MISSION-DATA>...</MISSION-DATA>
   <Sortie xlink:href="https://www.wbex.ru/"/>

</Mission> File: Schema.xsd <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

           targetNamespace="http://www.wbex.ru/unit/mission"
           xmlns="http://www.wbex.ru/unit/mission"
           xmlns:xlink="http://www.w3.org/1999/xlink/namespace"
           elementFormDefault="qualified">
   <xsd:import namespace="http://www.w3.org/1999/xlink/namespace"
               schemaLocation="xlink.xsd"/>
   <xsd:element name="Mission">
       <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="MISSION-DATA" type="xsd:string"/>
                <xsd:element name="Sortie" maxOccurs="unbounded"> 
                    <xsd:complexType>
                        <xsd:sequence/>
                        <xsd:attribute ref="xlink:href" use="required"/>
                    </xsd:complexType>
                </xsd:element>
           </xsd:sequence>
       </xsd:complexType>
   </xsd:element>

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

           targetNamespace="http://www.w3.org/1999/xlink/namespace"
           xmlns="http://www.w3.org/1999/xlink/namespace"
           elementFormDefault="qualified">
   <xsd:attribute name="href" type="xsd:anyURI"/>

</xsd:schema>

</source>
   
  


Use xlink to import another XML schema

   <source lang="xml">

File: Data.xml <?xml version="1.0"?> <Sortie xmlns="http://www.wbex.ru"

        xmlns:xlink="http://www.w3.org/1999/xlink/namespace"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation=
                  "http://www.wbex.ru
                   Schema.xsd">
   <SORTIE-DATA>...</SORTIE-DATA>
   <Aircraft xlink:href="https://www.wbex.ru"/>

</Sortie>

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

           targetNamespace="http://www.wbex.ru"
           xmlns="http://www.wbex.ru"
           xmlns:xlink="http://www.w3.org/1999/xlink/namespace"
           elementFormDefault="qualified">
   <xsd:import namespace="http://www.w3.org/1999/xlink/namespace"
               schemaLocation="xlink.xsd"/>
   <xsd:element name="Sortie">
       <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="SORTIE-DATA" type="xsd:string"/>
                <xsd:element name="Aircraft" maxOccurs="unbounded"> 
                    <xsd:complexType>
                        <xsd:sequence/>
                        <xsd:attribute ref="xlink:href" use="required"/>
                    </xsd:complexType>
                </xsd:element>
           </xsd:sequence>
       </xsd:complexType>
   </xsd:element>

</xsd:schema>

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

           targetNamespace="http://www.w3.org/1999/xlink/namespace"
           xmlns="http://www.w3.org/1999/xlink/namespace"
           elementFormDefault="qualified">
   <xsd:attribute name="href" type="xsd:anyURI"/>

</xsd:schema>

</source>