XSD扩展复杂类型

XSD扩展复杂类型,xsd,Xsd,我正在尝试扩展XSD文件中现有的complextype 我创建了一个新的xsd文件,并将其包含在所有主xsd文件的末尾 我遇到的问题是,它似乎添加了我的扩展,但删除了除asset_abstract中定义的元素之外的现有元素 我想做的事可能吗 我不想修改的代码 <xs:complexType name="Feature_Cadastre_Lot" abstract="false"> <xs:annotation> <xs:documentation>Repr

我正在尝试扩展XSD文件中现有的complextype

我创建了一个新的xsd文件,并将其包含在所有主xsd文件的末尾

我遇到的问题是,它似乎添加了我的扩展,但删除了除asset_abstract中定义的元素之外的现有元素

我想做的事可能吗

我不想修改的代码

<xs:complexType name="Feature_Cadastre_Lot" abstract="false">
<xs:annotation>
  <xs:documentation>Represents the boundary of a titled, or proposed lot</xs:documentation>
</xs:annotation>
<xs:complexContent>
  <xs:extension base="asset_abstract">
    <xs:sequence minOccurs="1" maxOccurs="1">
      <xs:element name="LotNo" type="String_32" minOccurs="1" maxOccurs="1" nillable="false">
        <xs:annotation>
          <xs:documentation>The lot number as described on the originating survey plan</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="PlanNo" type="String_32" minOccurs="1" maxOccurs="1" nillable="false">
        <xs:annotation>
          <xs:documentation>The plan number of the originating survey plan.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="CancelledLotPlan" type="String_32" minOccurs="1" maxOccurs="1" nillable="true">
        <xs:annotation>
          <xs:documentation>The lot on plan cancelled by this boundary if applicable.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="TitledArea_sqm" type="Float_Positive_NonZero" minOccurs="1" maxOccurs="1" nillable="false">
        <xs:annotation>
          <xs:documentation>The area in square metres enclosed by the boundary, as described by the survey plan.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Geometry" type="geometry_area_multipatch_simple" minOccurs="1" maxOccurs="1" nillable="false">
        <xs:annotation>
          <xs:documentation>The geometry of this feature in coordinate space.  May contain holes and islands. Boundaries must consist of straight lines.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:extension>
</xs:complexContent>

表示有标题或拟定地块的边界
原始测量平面图上描述的批号
原始测量平面的平面编号。
此边界取消的计划上的批次(如适用)。
测量平面图中描述的边界所包围的面积(以平方米为单位)。
此要素在坐标空间中的几何图形。可能包含洞和岛。边界必须由直线组成。

我可以导入代码以扩展方案

  <xs:complexType name="Feature_Cadastre_Lot">
<xs:complexContent>
    <xs:extension base="asset_abstract">
        <xs:sequence>
            <xs:element name="LMS_ID_1" type="String_32" minOccurs="1" maxOccurs="1" nillable="false">
                <xs:annotation>
                    <xs:documentation>The Land Management System ID as defined by the LMS Team</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="LMS_ID_2" type="String_32" minOccurs="1" maxOccurs="1" nillable="false">
                <xs:annotation>
                    <xs:documentation>The Land Management System ID as defined by the LMS Team</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:extension>
</xs:complexContent>

土地管理系统ID由LMS团队定义
土地管理系统ID由LMS团队定义

好吧,我已经创建了一个裸体的exmaple,但我现在仍然无法使用visual studio使其工作,因为我想确保它不是工具:),我仍然无法使其工作,因为您的是:(我一定错过了一些东西

基本上,我添加了两个文件Master.xsd和local.xsd Master包装了我不能/不想修改的远程项目direct and local.xsd是我们所有特定于站点的东西(重新定义它的名称)的位置

Master.xsd

    <?xml version="1.0"?>
<xs:schema version="1.0.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:include schemaLocation="project.xsd">
  </xs:include>
    <xs:include schemaLocation="local.xsd">
    <xs:annotation>
      <xs:documentation>A File I can add my overwrites to</xs:documentation>
    </xs:annotation>
  </xs:include>
  </xs:schema>

我可以将覆盖添加到的文件
project.xsd

    <?xml version="1.0"?>
<xs:schema version="1.0.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:include schemaLocation="remote.xsd">
    <xs:annotation>
      <xs:documentation>A File that contains the complexType I want to add elments to. But not modify otherwise</xs:documentation>
    </xs:annotation>
  </xs:include>
  <xs:element name="Master_Project">
    <xs:annotation>
      <xs:documentation>The Project.</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="ProjectData">
            <xs:complexType>
                <xs:sequence>
                <xs:element name="ExistingElement" type="ExistingElementType">
                  <xs:annotation>
                    <xs:documentation>An Existing Element That I would Like To Add To.</xs:documentation>
                  </xs:annotation>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

包含我要添加元素的complexType的文件。否则,不进行修改
这个项目。
我想添加到的现有元素。
local.xsd

    <?xml version="1.0"?>
<xs:schema version="1.0.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:redefine schemaLocation="./remote.xsd">
   <xs:complexType name="ExistingElementType">
      <xs:complexContent>
        <xs:extension base="ExistingElementType">
           <xs:sequence>
             <xs:element name="newTest"/>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>
</xs:redefine>
</xs:schema>

remote.xsd

<?xml version="1.0"?>
<xs:schema version="1.0.0" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="ExistingElementType">
   <xs:sequence>
      <xs:element name="someProperty"/>
      <xs:element name="someSecondProperty"/>
   </xs:sequence>
</xs:complexType>
</xs:schema>


如果你想将复杂类型的名称保留为“Feature\u Cadastre\u Lot”并用额外的内容扩展它,那么你需要重新定义。最终的效果是所有对“Feature\u Cadastre\u Lot”的引用,先前存在的和新的,将包括新添加的内容

如果您希望在某些内容(而不是所有现有内容)中使用此选项,则没有解决方案(重定义为全部或无)

重定义具有以下布局:

<xs:redefine schemaLocation="must resolve to your XSD">
  <xs:complexType name="Feature_Cadastre_Lot">
    <xs:complexContent>
      <xs:extension base="Feature_Cadastre_Lot">
        <xs:sequence>
            <xs:element name="LMS_ID_1" type="String_32" minOccurs="1" maxOccurs="1" nillable="false">
                <xs:annotation>
                    <xs:documentation>The Land Management System ID as defined by the LMS Team</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="LMS_ID_2" type="String_32" minOccurs="1" maxOccurs="1" nillable="false">
                <xs:annotation>
                    <xs:documentation>The Land Management System ID as defined by the LMS Team</xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:redefine>

土地管理系统ID由LMS团队定义
土地管理系统ID由LMS团队定义
结果如下所示:

您可以看到高亮显示的序列显示添加的内容

在Visual Studio 2010中,内容还显示“确定”:


请注意底部的第二个序列。

重定义似乎是我需要去做的方向。但是它似乎没有生效,它没有覆盖现有的功能\u地籍\u地块类型我缺少一些简单的东西…@Jamo,你能更具体地说明你是如何使用它的吗?例如,你正在使用某个编辑器,但你看不见修改后的关系图?或者您正在使用某种xsd到代码绑定工具(在这种情况下,可能不支持重定义)?我一直在使用XSDDiagram来帮助阅读该方案,但我也在visual studio中加载了它,但仍然不起作用。@Jamo,我已经更新了帖子,以显示QTAssistant和visual studio 2010中的重新定义;就我而言,结果如预期的那样显示;如果您的工具没有得到相同的结果,请归咎于:)…谢谢你的时间,我离你很近,我知道有些东西不适合我。我已经用一些例子更新了我的帖子,这些例子展示了项目布局以及我认为我将如何为本地站点修改它,我可以在Visual Studio中打开它,我看到了我的重新定义,但是它仍然没有使用重新定义的类型,而是使用初始类型。。。