我有一个具有本地complexType元素的模式,如下所示。XSD对本地complexType元素的限制
<xs:complexType name="AddressType">
<xs:sequence>
<xs:element name="Line1" type="xs:string" minOccurs="0"/>
<xs:element name="Line2" type="xs:string" minOccurs="0" maxOccurs="100"/>
<xs:element name="Location" minOccurs="0" maxOccurs="100">
<xs:complexType>
<xs:sequence>
<xs:element name="XCoordinate" type="xs:decimal" minOccurs="0"/>
<xs:element name="YCoordinate" type="xs:decimal" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
我想如下
<xs:complexType name="InternalAddressType">
<xs:complexContent>
<xs:restriction base="AddressType">
<xs:sequence>
<xs:element name="Location" >
</xs:element>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
我收到以下错误
**Error for type 'InternalAddressType'. The particle of the type is not a valid restriction of the particle of the base.
任何人都可以请帮助我了解什么我拨错做扩展这个复杂类型。看来问题在于该位置是本地ComplexType。但我无法改变,因为我从客户端获得了xsd,并且只需要扩展Loaction。我该如何解决这种情况。欢迎任何其他建议。
嗨@kjhughes,谢谢你的回复。我想要做的是给出上述架构(“InternalAddressType”)我想创建另一个架构(“InternalAddressType_1”),它具有与上述架构相同的结构,但具有更多元素。我本来可以去扩展,但问题是它不会让我在“位置”上做任何更改。我将不得不创建一个名为Location_1的新类型并在其中添加元素。因此,我将不得不维护两个不同的位置结构,它们都有部分数据。如果有多个位置实例,哪个是问题。 – Rush
计划进一步扩大/限制'InternalAddressType'到'InternalAddressType_1'只会加剧'AddressType'定义在'AddressType'(这是你无法控制的)方式的原始问题,它不能被覆盖。实际上,我认为你将不得不接受在给定这些约束的情况下你不能分享'AddressType'的'Location'的定义。 – kjhughes