I have xml file whose structure is defined with following 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.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>
Now I'm trying to create some test xml data based on previously defined xsd :
现在我正在尝试根据以前定义的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>
This xml file is considered invalid due to repeated "Items" elements. Is there any way around this?
由于重复的“Items”元素,此xml文件被视为无效。有没有办法解决?
1 个解决方案
#1
7
How about
<xs:element name="Items" maxOccurs="unbounded">
#1
7
How about
<xs:element name="Items" maxOccurs="unbounded">