我想从现有的模式文件中重新定义一些复杂的类型。当我使用Altova XMLSpy报告错误时。它显示:
重新定义类型定义“地址”必须是其自身的扩展或限制。 错误位置:xs:schema / xs:redefine / xs:complexType / xs:complexContent / xs:extension / @base 细节 src-redefine.5:重新定义类型定义“地址”必须是其自身的扩展或限制。
源代码中已经有<xs:extension>
部分。
<xs:redefine schemaLocation="reusable.xsd">
<xs:complexType name="Address">
<xs:complexContent>
<xs:extension base="Address">
<xs:sequence>
<xs:element name="PostCode"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
我无法弄清楚它有什么问题。这是我的架构文件的源代码。
Source.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="we:love:xml:schemas:but:we:hate:namespaces">
<xs:redefine schemaLocation="reusable.xsd">
<xs:complexType name="Address">
<xs:complexContent>
<xs:extension base="Address">
<xs:sequence>
<xs:element name="PostCode" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
<xs:element name="resume">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
提前致谢。
reusable.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xf="we:love:xml:schemas:but:we:hate:namespaces" targetNamespace="we:love:xml:schemas:but:we:hate:namespaces" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="Address">
<xs:annotation>
<xs:documentation>This is a type meant to represent a generic address. It consists of an
unlimited number of street addresses, a city, state or province, a postal code, and
country. It is suggested that if need be, on a transform use conditional processing
based on the Country element to get country specific layouts of the
addresses.</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="StreetAddress" type="xs:string" maxOccurs="unbounded"/>
<xs:element name="City"/>
<xs:element name="StateOrProvince" type="xs:string" minOccurs="0"/>
<xs:element name="PostalCode" type="xs:string"/>
<xs:element name="Country" type="xf:CountryType"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
答案 0 :(得分:0)
您选择的名称空间URI就是这么说的。你不想扩展“地址”,你想扩展“wlxsbwhns:Address”,其中前缀wlxsbwhns绑定到你的目标命名空间URI。