【发布时间】:2018-02-14 13:06:09
【问题描述】:
目标: 我有一个名为 Schema1.xsd 的现有标准 XSD。 我想在 Schema2.xsd 的 complexType("TVDSection") 中扩展 Schema1.xsd 的 complexType("tElementWithIDAndName")。
当我尝试在 Altova XMLSpy/oXygen xml 编辑器中验证 Schema2.xsd 时,我收到以下错误:
错误: [Xerces] cos-nonambig: "http://www.mySchema.com/Generic/1":element1 和 WC[##other:"http://www.mybasic.com/1",""] (或它们替换组中的元素)违反“唯一粒子属性”。在针对此模式进行验证期间,将为这两个粒子创建歧义。
Schema1.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.mybasic.com/1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
targetNamespace="http://www.mybasic.com/1"
elementFormDefault="qualified"
version="0.1">
<xs:complexType name="tElementWithIDAndName">
<xs:sequence>
<xs:element name="additionalName" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="id" type="xs:ID" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:complexType>
</xs:schema>
Schema2.xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.mySchema.com/Generic/1"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:myBasic="http://www.mybasic.com/1"
targetNamespace="http://www.mySchema.com/Generic/1"
elementFormDefault="qualified" version="0.1">
<xs:import namespace="http://www.mybasic.com/1" schemaLocation="schema.xsd"/>
<xs:element name="Element1" type="TVDSection"/>
<xs:complexType name="TVDSection">
<xs:complexContent>
<xs:extension base="myBasic:tElementWithIDAndName">
<xs:sequence>
<xs:element name="element1" type="xs:string" minOccurs="0" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
我不知道这是在哪里/如何违反了独特的粒子属性。 请帮我解决上述问题。
【问题讨论】:
标签: xml xsd xsd-validation xml-validation altova