Wednesday, July 18, 2007

XML Schema

Data types in XML schemas :
-------------------------------
1.primitive data types
2.derived data types
3.Atomic
4.List
5.union

Primitive datatype :
------------------------
primitive data types are fundamental datatypes of XSD.
These data types are the basis for defining other data types in XSD.
Primitive datatypes do not contain elements or attributes.
They contain only values.

Primitive Data type Description

string Represents a collection of characters.

decimal Represents decimal numbers.

float 32 bit floating point numbers

boolean

timeDuration Represents certain duration of time

recurringDuration represents a time duration that recurs after a specific interval.


Derived data types :

Derived data types are defined using other datatypes called basetypes.


Derived Data type Base Data type Description

integer Decimal

long Integer

nonNegativeInteger Integer

positiveInteger nonNegativeInteger

int Long

time recurringDuration

date timeDuration


Atomic data types :

Atomic data types can not be broken down into smaller units. These datatypes can be primitive or derived.
For Example, the string primitive data type cannot be further broken down into smaller units, such as characters.

List Datatypes :

Listdata types are derived data types that contain a set of values of atomic data types.For Example, we can derive a point list.


union datatypes :
Union data types are derived from the atomic and list data types .




The Purpose of XML schema : (XSD)

XML schema file is stored with .XSD extension.

XML schema file is used to validate the XML file. In other words, whether the XML file is formulated according to our user requirement can be tested with XML schemas .

XML file is nothing but an instance of a schema...

For Example :

we are defining structure as follows :



struct Allowance // This is what we call it as schema in XML, we call it as XML Schema available in .XSD file
{
float HRA;
float PF;
float ESI;
};



//XML instance this is similar to .XML file
Allowance s = new Allowance ();
s.HRA = 2000;
s.PF = 1000;
s.ESI = 200;



we can validate the .XML file based on the XML schema...

No comments: