【发布时间】:2011-10-13 23:28:38
【问题描述】:
我收到来自以下 XSD 的验证错误:
<?xml version="1.0" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="People">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Person" maxOccurs="unbounded">
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
使用以下 XML 进行验证时:
<?xml version="1.0" ?>
<People>
<Person name='john'>
a nice person
</Person>
<Person name='sarah'>
a very nice person
</Person>
<Person name='chris'>
the nicest person in the world
</Person>
</People>
返回以下错误:
lxml.etree.XMLSyntaxError: Element 'Person': Character content is not allowed, because the content type is empty.
我错过了什么?
【问题讨论】: