0% found this document useful (0 votes)
39 views4 pages

"1.0" "UTF-8" "Qualified" "Employee": XML Xs:schema

The document provides an example of an XML schema definition (XSD) for storing employee details including employee ID, name, and salary. The XSD schema restricts the employee ID to a range of 10-100, limits the first name to 12 characters, and defines salary fields with 2 decimal places. It also provides instructions for creating an XSD using Eclipse.

Uploaded by

Prabhakar Prabhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views4 pages

"1.0" "UTF-8" "Qualified" "Employee": XML Xs:schema

The document provides an example of an XML schema definition (XSD) for storing employee details including employee ID, name, and salary. The XSD schema restricts the employee ID to a range of 10-100, limits the first name to 12 characters, and defines salary fields with 2 decimal places. It also provides instructions for creating an XSD using Eclipse.

Uploaded by

Prabhakar Prabhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

XSD Example:

Consider Storing of employee details like eid,ename,esal.


eid should be in range of 10 to 100 and ename should have firstName and
lastName and firstName can be at max 12 characters.
esal should have basic and hra both should have fraction digits max : 2.
XSD:-
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/employee"
xmlns:tns="http://www.example.org/employee"
elementFormDefault="qualified">

<xs:element name="employee">
<xs:complexType>
<xs:sequence>

<xs:element name="eid">
<xs:simpleType>
<xs:restriction base="xs:int">
<xs:minInclusive value="10" />
<xs:maxInclusive value="100" />
</xs:restriction>
</xs:simpleType>
</xs:element>

<xs:element name="ename">
<xs:complexType>
<xs:sequence>

<xs:element name="fName">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="12" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="lName" type="xs:string" />

</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="esal">
<xs:complexType>
<xs:sequence>
<xs:element name="basic">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="2" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="hra">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:fractionDigits value="2" />
</xs:restriction>
</xs:simpleType>
</xs:element>

</xs:sequence>
</xs:complexType>
</xs:element>

</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Creating XSD using Eclipse :
Create a new Java Project -> right click on src-> new -> others-> XML Schema
(select this option). -> Next -> Enter File name-> Finish.

Ex 2:
Create XSD for storing book. book is root tag for xml and it must contains
bookId , bookName and bookCost. bookId range should be 10 to 500. And
author,version of book should be defined at last.
bookName should contains at max 15 characters. Author name must contain
firstName and last name. version should contain minor version and major
version.
Try This:

You might also like