从另一个xsd导入一个xsd中的complextype后,是否可以在第二个xsd中选择该复杂类型的子元素

从另一个xsd导入一个xsd中的complextype后,是否可以在第二个xsd中选择该复杂类型的子元素,xsd,Xsd,从另一个xsd导入一个xsd中的complextype后,是否可以在第二个xsd中选择该复杂类型的子元素 我的意思是: 我有第一个xsd。->AddressFile.xsd。在AddressFile.xsd中,有一个复杂类型IndividualAddress,包含5个子元素。在下一个xsd,Individual.xsd中,我指的是AddressFile.xsd中的complext类型IndividualAddress。但是在Individual.xsd中,我只需要直接从复杂类型Individua

从另一个xsd导入一个xsd中的complextype后,是否可以在第二个xsd中选择该复杂类型的子元素

我的意思是:

我有第一个xsd。->AddressFile.xsd。在AddressFile.xsd中,有一个复杂类型IndividualAddress,包含5个子元素。在下一个xsd,Individual.xsd中,我指的是AddressFile.xsd中的complext类型IndividualAddress。但是在Individual.xsd中,我只需要直接从复杂类型IndividualAddress中获取DoorNO、StreetNum和State。那有可能吗。我有什么限制吗

AddressFile.xsd

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"  
           targetNamespace="http://abc/DP/Address">
  <xs:complexType name="IndividualAddress">
    <xs:annotation>
      <xs:documentation>Address of an individual
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="DoorNO" type="xs:String" 
                  nillable="true" minOccurs="0"/>
      <xs:element name="StreetNum" type="xs:String" 
                  nillable="true" minOccurs="0"/>
      <xs:element name="State" type="xs:String" 
                  nillable="true" minOccurs="0"/>
      <xs:element name="Country" type="xs:String" 
                  nillable="true" minOccurs="0"/>
      <xs:element name="Pin" type="xs:String" 
                  nillable="true" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>
</xs:schema>
单个.xsd

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           xmlns:address="http://abc/DP/Address" 
           targetNamespace="http://abc/DP/Individual">

  <xs:import namespace="http://abc/DP/Address" 
             schemaLocation="AddressFile.xsd"/>

  <xs:complexType name="Individual">
    <xs:annotation>
      <xs:documentation>Address of an individual
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="Name" type="xs:String" 
                  nillable="true" minOccurs="0"/>
      <xs:element name="Age" type="xs:int" 
                  nillable="true" minOccurs="0"/>
      <xs:element name="DoorNO" type=" address:IndividualAddress " 
                  nillable="true" minOccurs="0"/>
      <xs:element name="StreetNum" type=" address:IndividualAddress " 
                  nillable="true" minOccurs="0"/>
      <xs:element name="State" type=" address:IndividualAddress " 
                  nillable="true" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

</xs:schema>

你最好的方法取决于你想要完成什么

如果希望XSD感知工具知道复杂类型IndividualAddress派生自复杂类型IndividualAddress,则可以从另一个派生一个。您需要分两个步骤来完成:一个是限制步骤,以消除不需要的基类型子元素,然后是扩展步骤,以添加更多的元素。不是一开始

如果您只想重用这些元素,那么基本模式的创建者已经尽了最大的努力来阻止您,通过使IndividualAddress本地类型的所有子项都成为本地类型,而这些子项不能从其他地方引用。如果他们想使重用变得容易,甚至可能,他们将a使有问题的元素成为顶级元素,和/或可能b使用命名的模型组来打包要一起使用的有用元素组