crr Posted September 17, 2013 Share Posted September 17, 2013 Hi, For the following XML block i was able to write the xsd code correctly: ----------- <job><year>1990-1995</year><company>A1 University</company><job_title>Professor</job_title></job><job><year>1995-2010</year><company>A2 University</company><job_title>Head of Department</job_title></job><job><year>2011-Present</year><company>A3 University</company><job_title>Research</job_title></job> ------------ as: <xsd:complexType name="jobtype"> <xsd:sequence> <xsd:element name="year" type="xsd:string"/> <xsd:element name="company" type="xsd:string"/> <xsd:element name="job_title" type="xsd:string"/> </xsd:sequence></xsd:complexType> ---------------- However if I want to enclose the XML block inside another tag (jobs) I am lost, can someone please help: <jobs> <job><year>1990-1995</year><company>A1 University</company><job_title>Professor</job_title></job><job><year>1995-2010</year><company>A2 University</company><job_title>Head of Department</job_title></job><job><year>2011-Present</year><company>A3 University</company><job_title>Research</job_title></job> </jobs> Thanks very much for any assistance. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 17, 2013 Share Posted September 17, 2013 I don't work with XML much, but wouldn't you just wrap the entire schema inside the definition for a jobs element? Link to comment Share on other sites More sharing options...
crr Posted September 18, 2013 Author Share Posted September 18, 2013 This is how I got it to work : <xsd:element name="jobs"> <xsd:complexType> <xsd:sequence> <xsd:element name="job" maxOccurs="unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name="year" type="xsd:string"/> <xsd:element name="company" type="xsd:string"/> <xsd:element name="job_title" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType></xsd:element> Thanks Link to comment Share on other sites More sharing options...
mrmacro Posted June 16, 2014 Share Posted June 16, 2014 What did was fine; as you have proven, it works. However, if the "jobs" element was one in a sequence, it would become obscured by the in-line element type definition. Since you already had a "jobtype" defined, you could have done the following: <xsd:element name="jobs"> <xsd:complexType> <xsd:sequence> <xsd:element name="job" type="jobtype" maxOccurs="unbounded"> </xsd:sequence> </xsd:complexType></xsd:element> As you can see this is easier to read which in your case is not important, but in a larger sequence it is much cleaner to define the types of the elements in the sequence and then just name the elements with their occurrence restrictions. I hope that this helps you and others with this type of problem in the future. Link to comment Share on other sites More sharing options...
Freelance-web-developer Posted June 26, 2014 Share Posted June 26, 2014 Crr provide a godd help. Link to comment Share on other sites More sharing options...
L8V2L Posted July 15, 2014 Share Posted July 15, 2014 What did was fine; as you have proven, it works.However, if the "jobs" element was one in a sequence, it would become obscured by the in-line element type definition. Since you already had a "jobtype" defined, you could have done the following: <xsd:element name="jobs"> <xsd:complexType> <xsd:sequence> <xsd:element name="job" type="jobtype" maxOccurs="unbounded"> </xsd:sequence> </xsd:complexType></xsd:element>As you can see this is easier to read which in your case is not important, but in a larger sequence it is much cleaner to define the types of the elements in the sequence and then just name the elements with their occurrence restrictions. I hope that this helps you and others with this type of problem in the future.Could you reword this? Link to comment Share on other sites More sharing options...
Eagleapk Posted January 18, 2021 Share Posted January 18, 2021 (edited) i also want to implement schema on [link removed] i don't know how to use schema please guide me Edited January 19, 2021 by Ingolme Removed advertising link Link to comment Share on other sites More sharing options...
Ingolme Posted January 19, 2021 Share Posted January 19, 2021 This topic is over 7 years old, please create a new topic for your question. Link to comment Share on other sites More sharing options...
Recommended Posts