Skip to main content

Data Formats ( XML & JSON ) XML AND JSON | Generate XSD for Persons

 

Generate XSD for Persons


Generate XSD for the following XML.

XYZ organization wants to store the details of persons in an xml file. The following scenario helps in designing the XML document.

Here PersonList  is the root tag. PersonList contains the entry of each person with adhaarno, name, age and address.

<?xml version="1.0"  encoding="UTF-8"?>
<PersonList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="PersonList.xsd">
    <Person>
        <adhaarno>414356782345</adhaarno>
        <name>
            <firstname>Zeenath</firstname>
        </name>
        <age>28</age>
        <address>
            <doorno>33</doorno>
            <street>Raidu Street</street>
            <city>coimbatore</city>
            <pincode>641039</pincode>
        </address>
    </Person>

    <Person Category="seniorcitizen">
        <adhaarno>414356782345</adhaarno>
        <name>
            <firstname>Simon</firstname>
        </name>
        <age>75</age>
        <address>
            <doorno>7</doorno>
            <street>Raja Street</street>
            <city>Chennai</city>
            <pincode>600005</pincode>
        </address>
    </Person>

    <Person>
        <adhaarno>414356782345</adhaarno>
        <name>
            <lastname>Varma</lastname>
        </name>
        <age>25</age>
        <address>
            <doorno>25</doorno>
            <street>cox street</street>
            <city>Bangalore</city>
            <pincode>560025</pincode>
        </address>
    </Person>
</PersonList>


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
 elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="PersonList">
<xs:complexType>
<xs:sequence>
<xs:element name="Person" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="adhaarno" type="xs:integer"/>
<xs:element name="name">
<xs:complexType>
<xs:choice>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="age" type="xs:integer"/>
<xs:element name="address">
<xs:complexType>
<xs:sequence>
<xs:element name="doorno" type="xs:integer"/>
<xs:element name="street" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="pincode" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Category" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Evaluation Result:


 

Result Description

Summary of tests
*Note: All the test cases might not have same weightage
+------------------------------+
|  1  test run/ 1  test passed |
+------------------------------+
 

Comments

Must Read:

Data Formats ( XML & JSON ) XML AND JSON | Pre-Quiz

  Feedback Congratulations!! You have passed by securing more than 80% Question  1 Correct Mark 1.00 out of 1.00 Flag question Question text What is the correct syntax in HTML for creating a link on a webpage? Select one: <link src="mcqsets.html"> <a href="mcqsets.html">   <a src="mcqsets.html"> <body link="mcqsets.html"> Feedback Your answer is correct. The correct answer is: <a href="mcqsets.html"> Question  2 Correct Mark 1.00 out of 1.00 Flag question Question text What are the new features in HTML5? Select one: All of these   Canvas element is provided for 2D drawing Better support for local storage Video and audio elements are available for media playbacK New form controls like calendar, date, time, email, URL, search  Feedback Your answer is correct. The correct answer is: All of these Question  3 Correct Mark 1.00 out of 1.00 Flag question Question text ____________ is the HTML5 attribute that speci...

Subscribe to Get's Answer by Email