1
<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:“序列”的内容必须匹配(注释?,(元素|组|选择|序列|任何)*)。发现问题始于:complexType。2号线

验证器错误 2:src-resolve:无法将名称“ExtendedQualification”解析为(n)“类型定义”组件。第 1 行

为什么会这样?

4

1 回答 1

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>标签作为子标签。您必须将它们包装在序列/选择/全部等中,然后<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>
于 2012-10-28T11:02:06.933 回答