XSD XML child 节点的验证错误

XSD validation error with XML child node

尝试根据外部 XSD 文件验证 XML 文件时出现验证错误。
我收到以下错误:cvc-complex-type.2.4.a:发现以元素 'namn' 开头的无效内容。应为“{name}”之一。
我想这与联系人嵌套 children...

有关

这是XML代码

<?xml version="1.0" encoding="ISO-8859-1" ?>

<startfalt>
    <person startnummer="14">
        <namn>
            <fornamn>Charlotte</fornamn>
            <efternamn>Kalla</efternamn>
        </namn>
        <fodelsesiffror>790204-1712</fodelsesiffror>
        <land>Sverige</land>
        <klubb>IK SKidan</klubb>
        <sponsor>Audi</sponsor>
        <traningstimmar>1200</traningstimmar>
        <prispengar valuta="kr">2300000</prispengar>
        <kontaktperson>
            <namn>
                <fornamn>Sven</fornamn>
                <efternamn>Svensson</efternamn>
            </namn>
        </kontaktperson>
    </person>
</startfalt>

这是我的架构

<?xml version="1.0" encoding="UTF-8" ?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified">

    <xsd:annotation>
        <xsd:documentation>Skidlandslaget</xsd:documentation>
    </xsd:annotation>

    <xsd:element name="startfalt">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="person" type="personType" minOccurs="1" maxOccurs="30" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

    <xsd:complexType name="personType">
        <xsd:sequence>
            <xsd:element name="namn" type="nameType" />
            <xsd:element name="fodelsesiffror" type="xsd:string" />
            <xsd:element name="land" type="xsd:string" />
            <xsd:element name="klubb" type="xsd:string" />
            <xsd:element name="sponsor" type="xsd:string" />
            <xsd:element name="traningstimmar" type="xsd:integer" />
            <xsd:element name="prispengar" type="priceType" />
            <xsd:element name="kontaktperson" type="contactType" />
        </xsd:sequence>

        <!--attribut for person-->
        <xsd:attribute name="startnummer" use="required">
            <xsd:simpleType>
                <xsd:restriction base="xsd:positiveInteger">
                    <xsd:pattern value="\d{2}"/>
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:complexType>

    <xsd:complexType name="nameType">
        <xsd:sequence>
            <xsd:element name="fornamn" type="xsd:string" />
            <xsd:element name="efternamn" type="xsd:string" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="priceType" mixed="true">
        <xsd:attribute name="valuta" use="required">
            <xsd:simpleType>
                <xsd:restriction base="xsd:string">
                    <xsd:enumeration value="sek" />
                    <xsd:enumeration value="kr" />
                </xsd:restriction>
            </xsd:simpleType>
        </xsd:attribute>
    </xsd:complexType>

    <xsd:complexType name="contactType">
        <xsd:sequence>
            <xsd:element name="name" type="contactNameType" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

您说得对,有一个相当简单的解决方法。将您的联系人类型更改为:

<xsd:complexType name="contactType">
    <xsd:sequence>
        <xsd:element name="namn" type="nameType" />
    </xsd:sequence>
</xsd:complexType>