import with namespace : import « XML Schema « XML






import with namespace


File: Data.xml
<?xml version="1.0"?>
<Unit xmlns="http://www.java2s.com/unit"
      xmlns:xlink="http://www.w3.org/1999/xlink/namespace"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation=
                   "http://www.java2s.com/unit
                    Schema.xsd">
    <myData>...</myData>
    <Mission xlink:href="https://www.java2s.com"/>
</Unit>


File: Schema.xsd

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.java2s.com/unit"
            xmlns="http://www.java2s.com/unit"
            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="Unit">
        <xsd:complexType>
             <xsd:sequence>
                 <xsd:element name="myData" type="xsd:string"/>
                 <xsd:element name="Mission"> 
                     <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>

 








Related examples in the same category

1.import another XML schema
2.import schema and elementFormDefault