[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Creating XSD

Posted on 2011-03-02
4
Medium Priority
?
315 Views
Last Modified: 2012-05-11
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! ^_^
0
Comment
Question by:Narusegawa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 35019834
You forgot one layer
<?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" >
                    <xs:complexType>
                        <xs:sequence maxOccurs="unbounded">
                            <xs:element name="Address" type="Address"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </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

0
 

Author Closing Comment

by:Narusegawa
ID: 35021152
Perfect!
0
 

Author Comment

by:Narusegawa
ID: 35021160
Thanks very much for that! It makes sense now.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35022175
welcome
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question