我有一个简单的
XML文件,我想针对XSD进行验证.
当我使用一些随机验证器进行验证时,我总是会收到以下错误:
当我使用一些随机验证器进行验证时,我总是会收到以下错误:
Invalid content was found starting with element ‘Entities’. One of ‘{Entities}’ is expected.
这是XML:
<BusinessModel xmlns="http://schemas.testxyzxyz.de/xyz/BusinessModel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Entities> <Entity Name="Customer"> <Attribute Name="Forename" Type="String" /> <Attribute Name="Surname" Type="String" /> <Attribute Name="Birthday" Type="Date" /> </Entity> </Entities> </BusinessModel>
和XSD一样:
<?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.testxyzxyz.de/xyz/BusinessModel" xmlns="http://schemas.testxyzxyz.de/xyz/BusinessModel"> <xsd:element name="BusinessModel" type="BusinessModelType" /> <xsd:complexType name="BusinessModelType"> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element name="Entities" type="EntitiesType" /> </xsd:choice> </xsd:complexType> <xsd:complexType name="EntitiesType"> <xsd:sequence> <xsd:element name="Entity" type="EntityType" maxOccurs="unbounded" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="AttributeType"> <xsd:attribute name="Name" type="xsd:string" use="required" /> <xsd:attribute name="Type" type="xsd:string" use="required" /> </xsd:complexType> <xsd:complexType name="EntityType"> <xsd:sequence> <xsd:element name="Attribute" type="AttributeType" maxOccurs="unbounded" minOccurs="1" /> </xsd:sequence> <xsd:attribute name="Name" type="xsd:string" use="required" /> </xsd:complexType> </xsd:schema>
从几小时开始寻找那个问题,我仍然没有发现错误.你能发现我正确的方向吗?