Breaking News

XML Schema Elements

A simple element is an XML element that can contain only text. It cannot contain any other elements or attributes.
However, the “only text” restriction is quite misleading. The text can be of many different types. It can be one of the types included in the XML Schema definition (boolean, string, date, etc.), or it can be a custom type that you can define yourself.
You can also add restrictions (facets) to a data type in order to limit its content, or you can require the data to match a specific pattern.
Note there are two types of XSD elements:
1. Simple
2. Complex
Here, we will be discussing simple Schema elements only.
Defining a Simple Element
The syntax for defining a simple element is:
<xs:element name=”element_name” type=”data_type”/>
in the above declration element_name is the name of the element you want to define and data_type is the type of data the element can contain.
XML Schema has a lot of built-in data types. The most common types are:
• xs:string
• xs:decimal
• xs:integer
• xs:boolean
• xs:date
• xs:time
XSL Data types
<name>Dharmendra Das</name>
<address_str>D 210</address_str>
<city>New Delhi</city>
And here are the corresponding simple element definitions:
<xs:element name=”name” type=”xs:string”/>
<xs:element name=”address_str” type=”xs:string”/>
<xs:element name=”city” type=”xs:string”/>
<xs:element name=”state” type=”xs:string”/>
<xs:element name=”city” type=”xs:string”/>
<xs:element name=”pin” type=”xs:integer”/>

Check Also

XML and Server

Generating XML with JSP   XML can be generated on a server without any installed …