我正在尝试在 XSD 文件中扩展现有的复杂类型。
我创建了一个新的 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>
好的,我已经创建了一个简单的示例,但我现在仍然无法使用 Visual Studio 让它工作,因为我想确保它不是工具 :),我仍然无法像你的那样工作 :( 我一定是遗漏了什么。
基本上,我添加了 2 个文件 Master.xsd 和 local.xsd Master 包装了我不能/不想直接修改的远程项目,而 local.xsd 是我们所有站点特定内容的地方(重新定义,因为它被称为)。
大师.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>
项目.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>
本地.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>
远程.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>
我最终在哪里进行所有重新定义。