I need to create an XSD for the XML file that we will use between systems so that we can check if the data we receive is really valid.
XML looks like this (but with lots of fields):
<Request>
<Request_ID>1000012295</Request_ID>
<Extra_Info>
<Item>
<Item_Number>0000000001</Item_Number>
<ItemDescription>test- 2</ItemDescription>
</Item>
<Item>
<Item_Number>0000000002</Item_Number>
<ItemDescription>test - 2</ItemDescription>
</Item>
</Extra_Info>
</Request>
and my XSD is as follows:
<?xml version="1.0" encoding="utf-16"?>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Request">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Request_ID" type="xsd:int" />
<xsd:element name="Extra_Info">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Item">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Item_Number" type="xsd:int" />
<xsd:element name="ItemDescription" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
This scheme works when I have only one Itemnode, but as soon as I have more than one, I get the following error:
The element 'Extra_Info' has an invalid child element 'Item'.
why doesn't it work if it is listed as a sequence?
Thank!
PS: I used this online validator for quick validation, but also getting the same error with XMLReader