验证时不确定 XML 和 XSD 错误

Unsure of XML and XSD errors when validating

我无法验证我的文件。

这是我遇到的错误。

-Errors in the XML document:
    9:  23  cvc-complex-type.2.4.d: Invalid content was found starting with element 'boardrelationships'. No child element is expected at this point.
    25: 23  cvc-complex-type.2.4.d: Invalid content was found starting with element 'boardrelationships'. No child element is expected at this point.
    40: 23  cvc-complex-type.2.4.d: Invalid content was found starting with element 'boardrelationships'. No child element is expected at this point.
    54: 23  cvc-complex-type.2.4.d: Invalid content was found starting with element 'boardrelationships'. No child element is expected at this point.
    67: 23  cvc-complex-type.2.4.d: Invalid content was found starting with element 'boardrelationships'. No child element is expected at this point.

-Errors in file xml-schema:
    11: 62  s4s-elt-must-match.1: The content of 'Name' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: element.

我将 post 我的 XML 文档代码和下面的 XSD 架构。我对此很陌生,所以我不确定自己做错了什么。我已经更改了我的文件格式,但我仍然遇到相同的错误...

<?xml version="1.0"?>
<KeyExecutives>
    <KeyExecutive>
        <Name>
            <first>Lawrence</first>
            <middle>Edward</middle>
            <last>Page</last>
        </Name>
        <boardrelationships>22</boardrelationships>
        <titles>
            <title>Co-Founder</title>
            <title>Chief Executive officer</title>
            <title>Director</title>
            <title>Member of Acquisition Committee</title>
            <title>Member of Executive Committee</title>
        </titles>
        <age>42</age>
    </KeyExecutive>
    <KeyExecutive>
        <Name>
            <first>Sergey</first>
            <middle></middle>
            <last>Brin</last>
        </Name>
        <boardrelationships>22</boardrelationships>
        <titles>
            <title>Co-Founder</title>
            <title>Director</title>
            <title>Member of Acquisition Committee</title>
            <title>Member of Executive Committee</title>
        </titles>
        <age>41</age>
    </KeyExecutive>
    <KeyExecutive>
        <Name>
            <first>Eric</first>
            <middle>E.</middle>
            <last>Schmidt Ph.D.</last>
        </Name>
        <boardrelationships>137</boardrelationships>
        <titles>
            <title>Executive Chairman</title>
            <title>Chairman of Executive Committee</title>
            <title>Chairman of Acquisition Committee</title>
        </titles>
        <age>60</age>
    </KeyExecutive>
    <KeyExecutive>
        <Name>
            <first>Ruth</first>
            <middle>M.</middle>
            <last>Porat</last>
        </Name>
        <boardrelationships>10</boardrelationships>
        <titles>
            <title>Chief Financial Officer</title>
            <title>Senior Vice President</title>
        </titles>
        <age>58</age>
    </KeyExecutive>
    <KeyExecutive>
        <Name>
            <first>Meir</first>
            <middle></middle>
            <last>Brand</last>

<?xml version="1.0"?>
<!-- XSD Schema for complex_apoole33_IT_MUST_VALIDATE.xml -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="KeyExecutives">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="KeyExecutive" maxOccurs="unbounded">
      <xsd:complexType>
        <xsd:sequence>
              <xsd:element name="Name">
                <xsd:element name="first" type="xsd:string"/>
        <xsd:element name="middle" type="xsd:string" minOccurs="0"/>
        <xsd:element name="last" type="xsd:string"/>
              <xsd:element name="boardrelationships" type="xsd:integer" minOccurs="0"/>
              <xsd:complexType>
                <xsd:sequence>
                  <xsd:element name="titles">
                    <xsd:element name="title" type="xsd:string" maxOccurs="unbounded"/>
              <xsd:element name="age" type="xsd:integer" minOccurs="0"/>
              </xsd:element>
                </xsd:sequence>
              </xsd:complexType>
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>

通过对您的 XSD 进行以下(大量结构性)修复(并从您的 XML 中删除 cut-off 元素),您的 XML 现在将成功验证反对你的 XSD:

XML

<?xml version="1.0"?>
<KeyExecutives>
  <KeyExecutive>
    <Name>
      <first>Lawrence</first>
      <middle>Edward</middle>
      <last>Page</last>
    </Name>
    <boardrelationships>22</boardrelationships>
    <titles>
      <title>Co-Founder</title>
      <title>Chief Executive officer</title>
      <title>Director</title>
      <title>Member of Acquisition Committee</title>
      <title>Member of Executive Committee</title>
    </titles>
    <age>42</age>
  </KeyExecutive>
  <KeyExecutive>
    <Name>
      <first>Sergey</first>
      <middle></middle>
      <last>Brin</last>
    </Name>
    <boardrelationships>22</boardrelationships>
    <titles>
      <title>Co-Founder</title>
      <title>Director</title>
      <title>Member of Acquisition Committee</title>
      <title>Member of Executive Committee</title>
    </titles>
    <age>41</age>
  </KeyExecutive>
  <KeyExecutive>
    <Name>
      <first>Eric</first>
      <middle>E.</middle>
      <last>Schmidt Ph.D.</last>
    </Name>
    <boardrelationships>137</boardrelationships>
    <titles>
      <title>Executive Chairman</title>
      <title>Chairman of Executive Committee</title>
      <title>Chairman of Acquisition Committee</title>
    </titles>
    <age>60</age>
  </KeyExecutive>
  <KeyExecutive>
    <Name>
      <first>Ruth</first>
      <middle>M.</middle>
      <last>Porat</last>
    </Name>
    <boardrelationships>10</boardrelationships>
    <titles>
      <title>Chief Financial Officer</title>
      <title>Senior Vice President</title>
    </titles>
    <age>58</age>
  </KeyExecutive>
</KeyExecutives>

XSD

<?xml version="1.0"?>
<!-- XSD Schema for complex_apoole33_IT_MUST_VALIDATE.xml -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="KeyExecutives">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="KeyExecutive" maxOccurs="unbounded">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="Name">
                <xsd:complexType>
                  <xsd:sequence>                
                    <xsd:element name="first" type="xsd:string"/>
                    <xsd:element name="middle" type="xsd:string" minOccurs="0"/>
                    <xsd:element name="last" type="xsd:string"/>
                  </xsd:sequence>
                </xsd:complexType>
              </xsd:element>
              <xsd:element name="boardrelationships" type="xsd:integer" minOccurs="0"/>
              <xsd:element name="titles">
                <xsd:complexType>
                  <xsd:sequence>                
                    <xsd:element name="title" type="xsd:string" maxOccurs="unbounded"/>
                  </xsd:sequence>
                </xsd:complexType>
              </xsd:element>
              <xsd:element name="age" type="xsd:integer" minOccurs="0"/>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>