[英]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.