You are on page 1of 2

XML Schema is commonly known as XML Schema Definition (XSD).

It is used to
describe and validate the structure and the content of XML data. XML schema
defines the elements, attributes and data types. Schema element supports
Namespaces. It is similar to a database schema that describes the data in a
database.The XML schema defines:

 Shape, or structure, of an XML document


 Rules for data content
 Semantics such as what fields an element can contain, which sub elements it
can contain and how many items can be present
 Type and values that can be placed into each element or attribute
 Data constraints, called facets and include rules such as min and max length

Sample XSD Sample XML

Simple Type

<Customer_dob>
<xs:element name="Customer_dob"
2000-01-12T12:13:14Z
type="xs:date" />
</Customer_dob>

<Customer_address>
<xs:element name="Customer_address"
99 London Road
type="xs:string" />
</Customer_address>

<OrderID>
<xs:element name="OrderID"
5756
type="xs:int" />
</OrderID>

Complex Types
<xs:element name="Customer"> <Customer>
<xs:complexType> <Dob>2000-01-12T12:13:14Z</Dob>
<xs:sequence> <Address> 34 thingy street,
<xs:element name="Dob" someplace, sometown, ww1 8uu
type="xs:date" /> </Address>
<xs:element name="Address" </Customer>
type="xs:string" /> <Supplier>
</xs:sequence> <Phone>0123987654</Phone>
</xs:complexType> <Address>22 whatever place,
</xs:element> someplace, sometown, ss1 6gy
<xs:element name="Supplier"> </Address>
<xs:complexType> </Supplier>
<xs:sequence>
<xs:element name="Phone"
type="xs:integer" />
<xs:element name="Address"
type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>

Global Complex Types

<xs:complexType
name="AddressType">
<xs:sequence>
<Address>
<xs:element name="Line1"
<Line1>An Address1</Line1>
type="xs:string" />
<Line2>An Address2</Line2>
<xs:element name="Line2"
</Address>
type="xs:string" />
</xs:sequence>
</xs:complexType>

<xs:element name="Customer">
<xs:complexType>
<Customer>
<xs:sequence>
<Dob>2000-01-12T12:13:14Z</Dob>
<xs:element name="Dob"
<Address>
type="xs:date" />
<Line1>34 thingy street,
<xs:element name="Address"
someplace</Line1>
type="AddressType" />
<Line2>sometown, ww1
</xs:sequence>
8uu</Line2>
</xs:complexType>
</Address>
</xs:element>
</Customer>
<xs:element name="Supplier">
<Supplier>
<xs:complexType>
<Phone>0123987654</Phone>
<xs:sequence>
<Address>
<xs:element name="Phone"
<Line1>22 whatever place,
type="xs:integer" />
someplace</Line1>
<xs:element name="Address"
<Line2>sometown, ss1 6gy</Line2>
type="AddressType" />
</Address>
</xs:sequence>
</Supplier>
</xs:complexType>
</xs:element>

You might also like