<xs:element name="qualificationRequired" type="ExtendedQualification"/>
<xs:complexType name="ExtendedQualification">
<xs:complexContent>
<xs:extension base="qualifications">
<xs:element name="other">
<xs:element name="skills" type="xs:string"/>
<xs:element name="languages" type="xs:string"/>
</xs:element>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:sequence>
</xs:complexType> //closes another complexType above
我的验证器返回以下错误:
验证器错误:s4s-elt-must-match.1:'sequence'的内容必须 match(annotation?,(element | group | choice | sequence | any)*)。一个 问题是从:complexType开始发现的。第2行
验证器错误2:src-resolve:无法解析名称 'ExtendedQualification'到(n)'类型定义'组件。第1行
为什么会这样?
答案 0 :(得分:2)
<xs:sequence>
小时候不能包含<xs:complexType>
。你必须把它放在其他地方。将其包装在元素中,有效地使其成为嵌套类型,或者将其作为全局类型直接放在<xs:schema>
元素中。
正如错误消息所示,您可以在<xs:sequence>
中放置的唯一标记是:
<xs:element>
<xs:group>
<xs:choice>
<xs:sequence>
<xs:any>
此外,<xs:extension>
不能将<xs:element>
标记作为子标记。您必须将它们包装在<xs:sequence>
,<xs:choice>
,<xs:all>
等中,具体取决于您希望实现的目标。
最后,<xs:element>
不能包含其他<xs:element>
代码作为子代。您必须将它们包装在序列/ choice / all等中,然后在<xs:complexType>
中以定义嵌套类型。或者把它全部移到外面作为全球类型。
这是一份有效的文件,定义了您上面要做的事情。我不了解整个文档,因此可能需要根据上下文进行调整。
<xs:schema version="1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:complexType name="blah"> <!-- You said there was a complexType open, I added its opening tag and gave it a placeholder name -->
<xs:sequence>
<xs:element name="qualificationRequired" type="ExtendedQualification"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ExtendedQualification"> <!-- the complexType is now removed from your sequence and is a global type-->
<xs:complexContent>
<xs:extension base="qualifications">
<xs:sequence> <!-- you can't have an element here, you must wrap it in a sequence, choice, all, etc. I chose sequence as it seems to be what you meant -->
<xs:element name="other">
<xs:complexType> <!-- same here, an element can't contain other element tags as children. For a complex element, you need a complexType. I defined it as a nested type -->
<xs:sequence> <!-- even complexType can't have element tags as children, again, I used a sequenct -->
<xs:element name="skills" type="xs:string"/>
<xs:element name="languages" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>