tags:

views:

460

answers:

1

I have xml file whose structure is defined with following 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"&gt;
  <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 :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Element xmlns="http://schemas.TEST.com/TEST/TEST.xsd"&gt;
   <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?

Thanks

+2  A: 

How about

<xs:element name="Items" maxOccurs="unbounded">
toolkit
thanks a lot, i sense that it has to do something with "maxOccurs" but not smart enough to test :-)
krul