first.xsd<?XML version= "1.0" encoding= "UTF-8"?><Xs:schemaXmlns:xs= "Http://www.w3.org/2001/XMLSchema"targetnamespace= "Www.myweb.com"xmlns= "Www.myweb.com"> <Xs:simpletypename= "Bid"> <xs:restrictionBase= "Xs:string"> <Xs:patternvalue= "[A]\d{6}"/> </xs:restriction> </Xs:simpletype></Xs:schema>
second.xsd<?XML version= "1.0" encoding= "UTF-8"?><Xs:schemaXmlns:xs= "Http://www.w3.org/2001/XMLSchema"xmlns= "Www.myweb.com"targetnamespace= "Www.myweb.com"> <Xs:simpletypename= "Aid"> <xs:restrictionBase= "Xs:string"> <Xs:patternvalue= "[C]\d{6}"/> </xs:restriction> </Xs:simpletype></Xs:schema>
third.xsd<?XML version= "1.0" encoding= "UTF-8"?><Xs:schemaXmlns:xs= "Http://www.w3.org/2001/XMLSchema"targetnamespace= "Www.myweb.com"xmlns= "Www.myweb.com"> <Xs:includeschemalocation= "First.xsd"/> <Xs:includeschemalocation= "Second.xsd"/> <xs:elementname= "Books"type= "InfoType"/> <Xs:complextypename= "InfoType"> <xs:sequence> <xs:elementname= "book"type= "BookType"/> </xs:sequence> </Xs:complextype> <Xs:complextypename= "BookType"> <xs:sequence> <xs:elementname= "title"type= "Xs:string"/> <xs:elementname= "Author"type= "Atype"/> </xs:sequence> <Xs:attributename= "BookID"type= "Bid"/> </Xs:complextype> <Xs:complextypename= "Atype"> <xs:sequence> <xs:elementname= "FirstName"type= "Xs:string"/> <xs:elementname= "LastName"type= "Xs:string"/> </xs:sequence> <Xs:attributename= "Authorid"type= "Aid"/> </Xs:complextype></Xs:schema>
Description
First.xsd: Defines a simple type and specifies that the target namespace is "www.myweb.com";
Second.xsd: Defines a simple type and specifies that the target namespace is "www.myweb.com";
Third.xsd: Define complex types, and reference first.xsd, Second.xsd, refer to these two schema files if the target namespace is consistent. Because third.xsd references first.xsd, second.xsd must specify the default namespace as "Www.myweb.com", otherwise it cannot reference the simple type data defined in Firtst.xsd, second.xsd;
Target namespace: Specifies the namespace from which the elements and data types that are constrained by this schema document are derived;
Default namespace: Specifies the namespace from which the elements and data types used in the current XML document are derived;
XML Schema include