元素必须没有字符或元素信息项[children],因为类型的内容类型为空 [英] Element must have no character or element information item [children], because the type's content type is empty
问题描述
当我从事这个项目时,我不断收到一条错误消息:
As I work on this project I keep getting an error saying:
元素客户"必须没有字符或元素信息项[children],因为该类型的内容类型为空.
Element 'Customer' must have no character or element information item [children], because the type's content type is empty.
我不知道为什么这不起作用,因为我按照说明进行操作,看起来像这样:
I am not sure why this is not working seeing I followed the notes and it looks like this:
<xs:element name="Customer" type="xs:string">
<xs:complexType>
<xs:attribute name="id" type="xs:integer" use="required"/>
</xs:complexType>
</xs:element>
我知道它是说我不能在其中包含 type="xs:string"
但是我如何让它必须有一个字符串?
I know it's saying I can't have the type="xs:string"
in there but then how do I make it have to have a string?
推荐答案
您需要修复 XSD 的 Customer
定义:将 xs:simpleContent
与 一起使用>xs:complexType
而不是您定义中的 xsl:element/@type
(customer.xsd):
You'll need to fix your XSD's definition of Customer
: Use xs:simpleContent
with xs:complexType
rather than xsl:element/@type
in your definition (customer.xsd):
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xs:element name="Customer">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:integer" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:schema>
上面的XSD然后会认为如下内容有效:
The above XSD will then consider content such as the following valid:
<Customer id="123">This is a string.</Customer>
这篇关于元素必须没有字符或元素信息项[children],因为类型的内容类型为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!