简体   繁体   English

元素'price'不能包含字符[children],因为类型的内容类型仅为元素

[英]Element 'price' cannot have character [children], because the type's content type is element-only

I am trying to validate my XML file against my XML Schema, however I am being given the following two errors for each item in my XML file: 我正在尝试根据我的XML Schema验证我的XML文件,但是我的XML文件中的每个项目都有以下两个错误:

cvc-complex-type.2.3: Element 'price' cannot have character [children], because the type's content type is element-only. cvc-complex-type.2.3:元素'price'不能包含字符[children],因为类型的内容类型只是元素。

cvc-complex-type.2.4.b: The content of element 'price' is not complete. cvc-complex-type.2.4.b:元素'price'的内容不完整。 One of '{"":one_and_half_litre}' is expected. 其中一个'{“”:one_and_half_litre}'是预期的。

Here is a sample of the XML file: 以下是XML文件的示例:

<soft_drinks>
    <drink>
        <name>Coca Cola</name>
        <price>â¬1.60</price>
    </drink>
    <drink>
        <name>Coca Cola Zero</name>
        <price>â¬1.60</price>
    </drink>
    <drink>
        <name>Coca Cola Diet</name>
        <price>â¬1.60</price>
    </drink>
    <drink>
        <name>Sprite</name>
        <price>â¬1.60</price>
    </drink>
    <drink>
        <name>Sprite Zero</name>
        <price>â¬1.60</price>
    </drink>
    <drink>
        <name>Fanta Orange</name>
        <price>â¬1.60</price>
    </drink>
    <drink>
        <name>Fanta Lemon</name>
        <price>â¬1.60</price>
    </drink>
</soft_drinks>

Below is the part of the XML Schema: 以下是XML Schema的一部分:

<xs:element name="soft_drinks">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="drink" maxOccurs="unbounded" minOccurs="0">
                        <xs:complexType>
                            <xs:sequence>
                                <xs:element name="name" type="xs:string"/>
                                <xs:element name="price">
                                </xs:element>
                            </xs:sequence>
                        </xs:complexType>
                    </xs:element>
                </xs:sequence>
            </xs:complexType>
        </xs:element>

Thanks if you can help!! 谢谢,如果你能帮忙!! :) :)

I think you need to add: 我想你需要添加:

type="xs:string"

to the price element. 到价格元素。

Hope it helps 希望能帮助到你

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 元素“设置”不能包含字符[children],因为类型的内容content-type仅是元素 - Element 'settings' cannot have character [children] because the type's content content-type is element-only 元素不能有字符 [children],因为该类型的内容类型是 element-only - Element cannot have character [children], because the type's content type is element-only cvc-complex-type.2.3:元素“group”不能有字符 [children],因为该类型的内容类型是 element-only - cvc-complex-type.2.3: Element 'group' cannot have character [children], because the type's content type is element-only cvc-complex-type.2.3:元素“项目”不能包含字符[children],因为类型的内容类型仅是元素 - cvc-complex-type.2.3: Element 'project' cannot have character [children], because the type's content type is element-only 针对XSD的XML验证:元素不能包含字符,因为类型的内容类型仅是元素 - XML validation against XSD: Element cannot have character, because the type's content type is element-only 元素必须没有字符或元素信息项[children],因为类型的内容类型为空 - Element must have no character or element information item [children], because the type's content type is empty cvc-complex-type.2.3:元素 'wsdl:definitions' 不能有字符,因为该类型的内容类型是仅元素。 当 xml 被验证时 - cvc-complex-type.2.3: Element 'wsdl:definitions' cannot have character, because the type's content type is element-only. when the xml is validated 验证XSD文件时出现问题:派生类型的内容类型及其基类的内容类型必须是混合的,或者两者都是仅元素的 - Problem validating an XSD file: The content type of a derived type and that of its base must both be mixed or both be element-only cvc-complex-type.2.3:元素“项目”不能具有字符子代 - cvc-complex-type.2.3 : Element 'Project' cannot have character children 一个元素的内联子元素,如果该类型只有一个元素 - Inline children of an element, if there's only one elements of that type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM