XSD验证失败:元素有“类型”属性和“匿名类型”子。其中只有一个元素可以用于元素。

时间:2021-07-02 17:15:26

When i validate the XSD file it gives the following error

当我验证XSD文件时,它给出了以下错误。

"src-element.3: Element 'Account' has both a 'type' attribute and a 'anonymous type' child. Only one of these is allowed for an element."

“src-element。3:元素“Account”有“type”属性和“匿名类型”子元素。其中只有一个元素是允许的。

<xsd:element name="AccountDetailsResponse">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="Account" type="account:Account">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="ID">
                            <xsd:complexType>
                                <xsd:sequence>
                                    <xsd:element type="xsd:string" name="NAME"/>
                                    <xsd:element type="xsd:string" name="PHONE"/>
                                    <xsd:element type="xsd:string" name="CATEGORY"/>
                                    <xsd:element type="xsd:int" name="LASTMODIFIED"/>
                                </xsd:sequence>
                            </xsd:complexType>
                        </xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>

Please help to resolve and make it a valid xsd.

请帮助解决并使其成为有效的xsd。

Thanks

谢谢

1 个解决方案

#1


1  

You've already got the answer. You have two choices:

你已经得到了答案。你有两个选择:

  • Remove the "type"-Attribute from your element with name="Account"
  • 从您的元素中删除“type”属性,名称为“Account”
  • Remove the "complexType"-Node in your element with name="Account"
  • 在元素中删除“complexType”节点,名称为“Account”

It's only allowed to do one of them, either you name a type or you anonymously define it inside.

它只允许做其中一个,要么你命名一个类型,要么你在里面匿名定义它。

#1


1  

You've already got the answer. You have two choices:

你已经得到了答案。你有两个选择:

  • Remove the "type"-Attribute from your element with name="Account"
  • 从您的元素中删除“type”属性,名称为“Account”
  • Remove the "complexType"-Node in your element with name="Account"
  • 在元素中删除“complexType”节点,名称为“Account”

It's only allowed to do one of them, either you name a type or you anonymously define it inside.

它只允许做其中一个,要么你命名一个类型,要么你在里面匿名定义它。