Link to home
Start Free TrialLog in
Avatar of Narusegawa
Narusegawa

asked on

Creating XSD

I'm trying to create an XSD for my XML structure, but I'm not sure this is right, I need a little help in the right direction.

My XSD is
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:element name="ContactDetails" type="Contact"/>

	<xs:complexType name="Contact">
	  <xs:sequence>
		<xs:element name="Surname" type="xs:string"/>
		<xs:element name="Firstname" type="xs:string"/>
		<xs:sequence>
			<xs:element name="Addresses" type="Address"/>
		</xs:sequence>
	  </xs:sequence>
	</xs:complexType>

	<xs:complexType name="Address">
	  <xs:sequence>
		  <xs:element name="Line1" type="xs:string"/>
		  <xs:element name="Line2" type="xs:string"/>
	  </xs:sequence>
	</xs:complexType>
	
</xs:schema>

Open in new window


Which when I 'generate xml sample' produces me this in VS2010

<?xml version="1.0" encoding="utf-8"?>
<ContactDetails>
  <Surname>Surname1</Surname>
  <Firstname>Firstname1</Firstname>
  <Addresses>
    <Line1>Line11</Line1>
    <Line2>Line21</Line2>
  </Addresses>
</ContactDetails>

Open in new window


But what I'm after is actually this

<?xml version="1.0" encoding="utf-8"?>
<ContactDetails>
  <Surname>Surname1</Surname>
  <Firstname>Firstname1</Firstname>
  <Addresses>
    <Address>
       <Line1>Line11</Line1>
       <Line2>Line21</Line2>
    </Address>
    <Address>
       <Line1>Line12</Line1>
       <Line2>Line22</Line2>
    </Address>
  </Addresses>
</ContactDetails>

Open in new window


What am I doing wrong in my XSD?

Thanks! ^_^
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Narusegawa
Narusegawa

ASKER

Perfect!
Thanks very much for that! It makes sense now.