.net 如何避免;元素';x';在命名空间中';x、 xsd&x27;具有无效的子元素';项目';在命名空间中';x、 xsd&x27&引用;?
我有一个xml文件,其结构由以下xsd定义:.net 如何避免;元素';x';在命名空间中';x、 xsd&x27;具有无效的子元素';项目';在命名空间中';x、 xsd&x27&引用;?,.net,xml,xsd,.net,Xml,Xsd,我有一个xml文件,其结构由以下xsd定义: <?xml version="1.0" encoding="utf-8"?> <xs:schema targetNamespace="http://schemas.TEST.com/TEST/TEST.xsd" elementFormDefault="qualified" xmlns="http://schemas.TEST.com/TEST/TEST.xsd" xmlns:mstns="http://schemas.TEST.co
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://schemas.TEST.com/TEST/TEST.xsd" elementFormDefault="qualified" xmlns="http://schemas.TEST.com/TEST/TEST.xsd" xmlns:mstns="http://schemas.TEST.com/TEST/TEST.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Element">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Items">
<xs:complexType>
<xs:sequence>
<xs:element name="ItemName" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
现在,我尝试基于先前定义的xsd创建一些测试xml数据:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Element xmlns="http://schemas.TEST.com/TEST/TEST.xsd">
<Name>John Blue</Name>
<Items>
<ItemName>test</ItemName>
</Items>
<Items>
<ItemName>test2</ItemName>
</Items>
<Items>
<ItemName>test3</ItemName>
</Items>
</Element>
约翰·布鲁
测试
测试2
测试3
由于重复的“Items”元素,此xml文件被视为无效。
有什么办法解决这个问题吗?怎么样
<xs:element name="Items" maxOccurs="unbounded">
非常感谢,我感觉它必须与“maxOccurs”相关,但不够智能,无法测试:-)