Generate XSD 4

Question:

Generate an XSD for the following XML document

<?xml version=”1.0″ encoding=”UTF-8″?>

<company>

<employee>

<id>101</id>

<name>Ram</name>

<salary>10000</salary>

<email>ram@gmail.com</email>

</employee>

<employee>

<id>102</id>

<name>Dinesh</name>

<salary>20000</salary>

<email>dinesh@gmail.com</email>

</employee>

<employee>

<id>103</id>

<name>sathish</name>

<salary>20000</salary>

<email>sathish@gmail.com</email>

</employee>

<employee>

<id>104</id>

<name>Praveen</name>

<salary>20000</salary>

<email>praveen@gmail.com</email>

</employee>

</company>

Code:

employee.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs ="http://www.w3.org/2001/XMLSchema">
<xs:element name="company">
<xs:complexType>
<xs:sequence>
<xs:element name = "employee" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:integer" name="id" />
<xs:element type="xs:string" name="name" />
<xs:element type="xs:integer" name="salary" />
<xs:element type="xs:string" name="email" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Recommended:

Leave a Comment

Your email address will not be published. Required fields are marked *

x