我有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
<?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>
由于重复的“Items”元素,此xml文件被视为无效.
有没有办法解决?
<xs:element name="Items" maxOccurs="unbounded">