Introduction
XML என்பது Extensible mark up language ஆகும். இது World Wide Web Consortiums (W3C)-ஆல் Standard generalized mark up language (SGML)-ஐ use செய்து develop செய்யப்பட்டுள்ளது. ஆனால் இது SGML மற்றும் HTML language-லுள்ள problem-ஐ overcome செய்கிறது. இது developer-ஆல் describe செய்யப்படும் எல்லா information-க்கு support செய்கிறது.
இந்த language use செய்வதன் மூலம் developer-ன் own data-வையும் user defined tag மூலம் describe செய்ய முடியும்.
Advantage of
XML
- இது பெரிய அளவிலுள்ள complex data, file மற்றும் structured document-க்கு support செய்கிறது.
- User-க்கு தேவைப்படும் எந்த வகையான document-யும் arrange செய்ய முடியும்.
- இது மிகவும் complex மற்றும் application specific problem-க்கு support செய்கிறது.
- இது document-ல் searching மற்றும் sorting பொன்றவற்றிற்கு support செய்கிறது.
- Internet-ல் இது free ஆக கிடைக்கிறது.
- User எந்த வகையான calculation (manipulation)-யும் XML data-வில் செய்ய முடியும்
HTML VS XML
Browsing and parsing XML
Browsing XML
Browsers என்பது
XML document-ஐ run செய்ய உதவும் software ஆகும் XML document-ல் அடிக்கடி use செய்யவும்
browser-கள் கீழே கொடுக்கப்பட்டுள்ளன.
(i) Internet Explorer
(ii) Netscape
Navigator 6.0
(iii) Opera
4.0
Parsing XML
Parsing என்பது
document-ன் grammatical structure-ஐ check செய்ய
உதவும் software ஆகும். அதாவது XML specification-ல் உள்ள document-ஐ check
செய்ய பயன்படுகிறது error ஏற்பட்டால் correction செய்வதர்கு இது report செய்கிறது.
Parser பொதுவாக ஏற்கனவே browser-ல் built-ஆகி இருக்கும்.
இரண்டு வகையான XML parser-கள் உள்ளது.
(i) Non-validating
parsers
(ii) Validating
parsers
(i) Non-validating parsers
இந்த parser கீழ்கண்டவற்றை செய்கிறது.
(a) இது
XML document-ஐ read செய்கிறது
(b) இது
document, well format-ல் அதாவது syntax error-ஐ check செய்கிறது.
(ii) Validating
parsers
இந்த parser, non validating parser-லிருந்து well format document-ஐ எடுத்து கீழ்கண்டவற்றை செய்கிறது.
(a) இது
document-ல் ஏதேனும் ஒரு definition (DTD)-ல் எழுதப்பட்டுள்ளதா என்பதை verify செய்கிறது.
(b) இது
XML schema மற்றும் வெறு வகையான validation-ஐ verify செய்கிறது.
Creating a XML file
(ii) இங்கு
நமது user defined tag-ஐ use செய்து கீழ்கண்ட type-ல் text book பற்றிய
information-ஐ type செய்ய வேண்டும்.
<? XML version=”1.0”?>--à XML specification called XML declaration
<Books>
<Book>
<Tittle>Internet Concepts</Tittle>
<Author>IED and RKS</Author>
<Price> Rs150 </Price>
<Publisher> NV </Publisher>
</Book>
</Books>
The user defined tags are
(a) <Books>-----------</Books>à main element
(b) <Book>-----------</Book>à sub element
(c) <Tittle>-------------</Tittle>
(d) <Author>-----------</Author>
(e) <Price>-------------</Price>
(f) <Publisher>---------</Publisher>
(iii) .XML
extension-ல் save செய்ய வேண்டும். உதாரணமாக book.xml
(iv) Internet
explorer-ஐ open செய்து book.XML document-ஐ run செய்ய வேண்டும். கீழ்கண்ட Window
book.XML document-ன் output-ல் தெரிகிறது
<Books>
<Book>
<Tittle> Internet Explorer </Tittle>
<Author> IED and RKS </Author>
<Publisher> NV </Publisher>
</Book>
DATA ISLAND
Data Island என்பது html code-ல் XML-ஐ embed செய்வதற்கான method
ஆகும்.
இந்த method, html-ஐ use செய்து data-வை store மற்றும் manipulate செய்கிறது. Html-லுள்ள
tag DIV, SPAN பொன்றவற்றின் data field attribute-ஐ பயன்படுத்தி XML tag-ஐ HTML-ல்
add செய்ய முடியும்.
கீழ்கண்ட step-ஐ பயன்படுத்தி
table-ல் html-லுள்ள data island செய்ய முடியும்.
(i) User
define செய்த tag-ஐ பயன்படுதி XML document-ஐ creat
செய்த பிறகு அதனை XML extension-ல் store செய்ய
வேண்டும்.
செய்த பிறகு அதனை XML extension-ல் store செய்ய
வேண்டும்.
(ii) Create
செய்த html document-ஐ ஏற்கனவே create செய்த XML
document உடன் create செய்வது கீழே தரப்பட்டுள்ளது.
<html>
<body>
<XML id=”name of the created data using XML” SRC=”name of the
XML file”>
</XML>
<Table colspan=”value” rowspan=”value data scr =”#name same as id field in
XML TAG”>
---------------
---------------
<tr>
<td><DIV data fld=”tag l in XML”></DIV></td>
-------------
-------------
<td><DIV data fld = tag n in XML”></DIV></td>
</table>
Table tag-லுள்ள datasrc attribute HTML table-ஐ XML data island-ஆக
மாற்ற பயன்படுகிறது.
document உடன் create செய்வது கீழே தரப்பட்டுள்ளது.
<html>
<body>
<XML id=”name of the created data using XML” SRC=”name of the
XML file”>
</XML>
<Table colspan=”value” rowspan=”value data scr =”#name same as id field in
XML TAG”>
---------------
---------------
<tr>
<td><DIV data fld=”tag l in XML”></DIV></td>
-------------
-------------
<td><DIV data fld = tag n in XML”></DIV></td>
</table>
Table tag-லுள்ள datasrc attribute HTML table-ஐ XML data island-ஆக
மாற்ற பயன்படுகிறது.
Example - Information about book
Step 1 - Create a book XML document named book.xml using
notepad
<?XML
version=”1.0”>
<Books>
<Book>
<Tittle>Internet
Concepts</Tittle>
<Author>
IED and RKS </Author>
<Price>
Rs.150 </Price>
<Publishers>
NV </Publishers>
</Book>
<Book>
<Tittle>
Java Programming </Tittle>
<Author>
IED and RKS </Author>
<Price>
Rs.150 </Price>
<Publishers>
NV </Publishers>
</Book>
</Books>
Store this XML document as book.xml
Step 2 – Create the following html document named example.html using the notepad.
<head>
<Tittle>Book data</Tittle>
</head>
<Body>
<XML id=”books Catalogue” src=”book.xml”></XML>
<Table border=”1”
colspan=”4” row span=”4” data src=”Books Catalogue”>
<Thead>
<tr>
<th>Book
tittle</th>
<th> Author
</th>
<th> Price
</th>
<th>Publisher</th>
</Thead>
<tr>
<td><Div
data fld=”Title”></Div></td>
<td><Div
data fld=”Author”></Div></td>
<td><Div
data fld=”Price”></Div></td>
<td><Div
data fld=”Publisher”></Div></td>
<tr>
</table>
</html>
Store in this html document as example.html
Step 3 – Internet Explore-ஐ use செய்து example html-ஐ run செய்ய வேண்டும்
கீழ்கண்ட படத்தில் output கொடுக்கப்பட்டுள்ளது.
கீழ்கண்ட XML
sysntax rule-ஐ பயன்படுத்தி well formed XML document-ஐ XML document-ஆக define செய்யலாம்.
Well formed XML
document-ஐ எழுத கீழ்கண்ட முக்கியமான rule-ஐ பின்பற்ற வேண்டும்.
(i) Start மற்றும் end tag கண்டிப்பாக match ஆக வேண்டும்.\
Example
<Book> ------ </Book>
(ii) XML
tag-கள் case sensitive உடையது
Example
<Book>
------ </book>
It is not valid
<Book> ------ </Book>
It is valid
(iii) Element
–களை overlap பண்ண முடியாது
Example
<Book>
<Title>Maths</Book>
</Tittle>
It is not valid because book and tittle elements overlaps.
(iv) ஒவ்வொரு XML document-ம் unique root element-ஐ கொண்டிருக்கும்.
<Tittle>-----------</Tittle>
<Author>---------</Author>
</Book>
XML Components
XML document-கள் கீழ்கண்ட (building blocks) component-ஆல் develop-ஆல் develop செய்யப்படுகிறது. அவைகள்
(i) Elements
(ii) Entities
(iii) Comments
(iv) Processing istructions
(v) Attributes
Elements என்பது markup tag மற்றும் element content-ஐ கொண்டிருக்கும். இதன் பொது வடிவம்
<element name>
--------------------
--------------------
<element name>
where
<> - opening tag
</> - closing tag
element name - valid element name
Rules:
(i) Element name, letters, number மற்றும் வெறு characters-யும் கொண்டிருக்கும்.
(ii) Element name கண்டிப்பாக number அல்லது punctuation character உடன் துவங்க வேண்டும்.
(iii) Element name-ல் blank space இருக்கக்கூடாது .
(iv) இந்த element வேறு element மற்றும் simple text-ஐ கொண்டுள்ளது.
Example:
(i) <Book> ----------------</Book>
(ii) <Book>
<Title>------------------</Title>
<Author>---------------</Author>
</Book>
இந்த book element, book detail பற்றிய content-ஐ கொண்டுள்ளது. இதனால் இந்த element, document element-ஆல் குறிப்பிடப்படுகிறது.
(ii) Entities
Entity என்பது XML content-க்கு name கொடுக்கும். இந்த name-ஐ பயன்படுத்தி XML document-ல் எந்த பகுதியிலிருந்தும் உள்ள content-ஐ refer செய்ய முடியும். Entity-ஐ declare செய்ய உதவும் பொதுவடிவம்.
<!ENTITY entityname"entitycontent"
where
!ENTITY - keyword
entity name - valid name
கீழ்கண்ட பொது வடிவம் மூலமாக entity content-ஐ XML document-ஆல் refer செய்ய முடியும்.
entityname;
Example
<!ENTITY CT "Computer Technology">
இதில் computer technalogy content-லுள்ள entity name CT என define செய்யப்படுகிறது. அந்த content-ஐ document-ன் எந்த ஒரு பகுதியிலிருந்தும் refer செய்ய முடியும்.
<Dept> & CT; </Dept>
மூன்று வகையான entity-கள் உள்ளன.
(a) Predefined entity
இந்த entities XML-ல் define செய்த entity ஆகும். கீழ்கண்ட சில முக்கியமான predefined entity-கள் தரப்பட்டுள்ளது.
Entity Content
& &
&It; <
> >
" "
' "
Example:
<salary>if amount &IT; 1000the</salary>
(b) External entities
இந்த entity external file contetn-ஐ access செய்ய பயன்படுகிறது. இதன் பொதுவடிவம்
<!ENTITY entityname SYSTEM"URI/URL">
where
!ENTITY SYSTEM - keywords
entityname - valid name
URL/URI - name of the file
Example
<!ENTITY author SYSTEM "http://ed.com">
(c) Parameter entities
Parameter entities என்பது DTD-ல் உள்ளே இருக்கும் entities ஆகும். இந்த parameter entity name முன்னால் % போடப்பட்டு இருக்கும். இந்த name-க்கு முன்னால் இருக்கும் % கொண்டு இதனை identify செய்து கொள்ளலாம்.
(iii) Comments
Comments என்பது program code-லுள்ள explanation-ஐ கொடுக்க use செய்யும் statement ஆகும். இந்த statement execute ஆகாது. இதன் பொது வடிவம்
<!valid explanation>
Example:
<!program to define books Information>
(iv) Processing instructions
Processing instruction என்பது outside data source-லிருந்து data-வை பெற்று XML document-லுள்ள (Processing Instruction) PI-ஐ Include செய்ய உதவும் பொதுவடிவம்.
<?PI targetname instruction code to get data?>
where
<?,?> - opening and closing tag
target name - processed instruction-ல் உள்ள data-வை hold செய்வதர்கு valid XML element-ஐ கொண்டிருக்கும்.
PI - key word
instruction code - valid instruction to get data from outside source.
Example:
<?Polytechnic select * from student ? >
இந்த Instruction process ஆகும் போது student table-லுள்ள data-வை read செய்ய PI target Polytechnic-ல் store செய்கிறது. இந்த data XML document use செய்யும் application-க்கு pass ஆகிறது.
(v) Attributes
Attribute , element பற்றிய extra information-ஐ தருகிறது. Attribute-கள் start tag
element-ன் உள்ளே இருக்கும் இதன் பொதுவடிவம்,
<elementname attribure 1 ="value 1"
attribute2= "value 2" ------------------
attributen="value n">
where
elementname - valid element
attribute 1.. attribute n - attributes
value 1 ............value n - value given to the attributes
Attribute types
(i) CData
இந்த attribute எந்த ஒரு string மற்றும் அதன் value-ஐயும் எடுக்கிறது.
Example:
<actor role="joker">
where role is the attributes of the element joker. This takes a string value.
(ii) Enumerator type
Enumerator என்பது possible attribute value-ஐ list செய்யும் ஒரு technique ஆகும். இதிலிருந்து அந்த value-யும் நாம் use செய்ய முடியும்.
இதன் பொதுவடிவம்
<!ATTLIST cast name (value 1/value 2/.....value n)"default value">
where
cast - element name
name - attribute name
value1/...valuen - attribute values
இந்த attributes ஏதேனும் ஒரு predefined value, value 1,....... value n-ஐ கொண்டிருக்கும். இந்த value-ஐ attribute-ன் value-ஆக கொடுக்க முடியாது. இது default value-ஐ கொண்டிருக்கும்.
Example
<ATTLIST type (male/female/unknown)"unknown">
<message/"male"/>
(iii) ID
XML document element-ஐ identity செய்ய ID type பயன்படுகிரது. இதன் பொது வடிவம்.
<element id="value">
Example:
<little id= "3">
கீழ்கண்ட table-ல் முக்கியமான attribute-ன் list கொடுக்கப்பட்டுள்ளது
TYPE EXPLANATION
CDATA இதன் value character data ஆகும்.
(eval/eval/..) இதன் value enumerated value ஆகும்.
ID இதன் value unique ID ஆகும்.
IDREF இதன் value வேறு element-ன் id ஆகும்.
IDREFS வேறு ID-யின் list d-யின் value ஆகும்.
NMTOKEN Valid XML name-ன் value.
NMTOKENS The value is a list of valid XML names
ENTITY Entity-ன் value.
ENTITIES Entities list-ன் value.
NOTATION Notation name-ன் value
XML: இந்தvalue predefined ஆகும்.
DTD
DTD என்பது Document Type Definition-ன் விரிவாக்கம் ஆகும். இது XML document-லுள்ள legal building block-ஐ define செய்து use செய்ய பயன்படுகிறது.
DTD, XML document-க்கு உள்ளே அல்லது வெளியில் define செய்ய முடியும். XML document-க்கு உள்ளே DTD define செய்தால் அது internal DTD என்றும் வெளியே define செய்தால் external DTD என்று அழைக்கப்படும்.
Declaration in DTD
Declaration in DTD என்பது element, attribute, entities மற்றும் notation போன்ற basic ஆன building block-ஐ declare செய்யும் process ஆகும்.
Declaring elements in DTD
DTD element-ஐ declare செய்யும் பொதுவடிவம்.
<!ELEMENT element name (element content)>
where
ELEMENT - key word
element name - user defined name
element content - sub elements names
Example:
Consider the following XML program
<Purchase Order>
<Shipping Information>
<Name>IED</Name>
<Address>
<Street>new street</Street>
</Address>
</Shipping Information>
<Billing Information>
<Name>RKS</Name>
<Address>
<Street>middle street</Street>
</Address>
</Billing Information>
</Purchase Order>
இந்த example-ல் உள்ள ஒரு main element purchase order-ம் இரண்டு Sub elements Shipping Information மற்றும் Billing Information-ஐ கொண்டிருக்கும்.
மேலே உள்ள example-ல் உள்ள DTD element-ஐ declare செய்யும் structure கீழே தரப்பட்டுள்ளது.
<ELEMENT Purchase Order (Shipping Information,Billing Information)>
<!ELEMENT Shipping Information (Name, Address)>
<!ELEMENT Address (Street)>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Street (#CDATA)>
where
#PCDATA - parsed character Data. Gives the datatype of the value
#CDATA - character Data. Gives the datatype of the value
Declaring attributes in DTD
Attributes-கள் XML document-ல் use ஆகும். element பற்றிய extra information-ஐ கொடுக்கிறது. DTD-லுள்ள ATTRIBUTE-ஐ declare செய்ய உதவும் பொதுவடிவம்.
<!ATTLIST elementname attributename attribute-type default-value>
where
elementname - element-ன் name
attributename - attribute-ன் name
attributetype - CDATA, PCDATA போன்றவற்றை attribute-ன் name
default value - attribute-ன் default value
The default values are
(i) #DEFAULT "VALUE"
இந்த attribute default value-ஐ கொண்டிருக்கும்.
(ii) #REQUIRED
இந்த attribute value element-ல் கண்டிப்பாக included செய்ய வேண்டும்.
(iii) #IMPLIED
இந்த attribute include செய்ய வேண்டியதில்லை.
(iv) #FIXED "VALUE"
இந்த attribute value fix ஆக இருக்கும்.
Example: Consider the XML code given below.
(i) <Person number="5677">
DTD for this code is
<!ATTLIST person number CDATA #REQUIRED>
(ii) <contact fax = "044-2775787">
DTD for this code is
<!ATTLIST contact fax CDATA #IMPLIED>
(iii) <Sender company "Numeric">
DTD for this code is
<!ATTLIST Sender company CDATA #FIXED "NUMERIC">
Declaring entites in DTD
Internal entity-ஐ declare செய்வதற்கான பொதுவடிவம்
<!ENTITY entityname"entityvalue">
where
entityname - entity-ன் name
entityvalue - entity-ன் value
Example - Consider the XML code given below
<author>&writer; ©right;</author>
The DTD for this code is
<!ENTITY writer "IED and RKS">
<!ENTITY copyright "NV">
The general form to declare external entity is
<!ENTITY entity-name SYSTEM "URI/URL">
where
entity-name - entity-ன் name
SYSTEM - keyword
URI/URL - Value-ன் address-ஐ find செய்கிறது
Example - Consider the XML code given below.
<author>&writer; ©right; </author>
The DTD for this code is
<!ENTITY writer SYSTEM "http://ed.com">
<!ENTITY copyright SYSTEM "http://nv.com">
Declaring notations in DTD
Notation என்பது text இல்லாத data (non textual data)-வின் format-ஐ identity செய்யும் ஒரு special declaration ஆகும்.
The general form to declare notation is
<!NATAION naotationname [SYSTEM/PUBLIC] dataformat>
where
notationname - இது notation-ன் name
SYSTEM - இது system-ல் define செய்யும் notation-ன் format-ஐ parser-க்கு கொடுக்க பயன்படுகிறது
PUBLIC - இது system-ன் outside-ல் define செய்யும் notation-ன் format-ஐ parser-க்கு கொடுக்க பயன்படுகிறது
dataformat - இது use செய்யும் data format-ன் definition-ஐ கொடுக்கிறது.
Example:
(i) bird.gif
இங்கே .gif என்ற notation, bird file graphics interchange format-ல் store ஆகி உள்ளதை காட்டுகிறது.
Notation-ஐ declare செய்யும் பொதுவடிவம்.
(ii) கீழ்கண்ட XML code-ஐ consider செய்க.
<employee pic = "photo">
The DTD for this code is
<!NOTATION gif SYSTEM "image/gif">
Construction of a XML document using DTD
DTD-ல் program write செய்வதற்கான பொதுவடிவம்
<!DOCTYPE NAME [
ELEMENT declaration 1
------------------------------
------------------------------
ELEMENT declaration n
------------------------------
------------------------------
ATTLIST declaration 1
----------------------------
----------------------------
ATTLIST declaration n
]>
where
DOCTYPE - keyword
NAME - XML document-லுள்ள main (root) element-ன் name
XML Document-ல் Create செய்வதற்கான steps.
- Root element-ஐ declare செய்ய வேண்டும்.
- Root element-ன் attribute-ஐ declare செய்ய வேண்டும்.
- Sub element-ஐ declare செய்ய வேண்டும்.
- Sub element-ன் attribute-ஐ declare செய்ய வேண்டும்.
- எல்லா sub element மற்றும் அதனுடய attribute-யும் declare செய்யும் வரையில் இந்த process-ஐ repeate செய்ய வேண்டும்
XML program
<? XML version ="1.0">
<Book Author="IED">
<Tittle> Internet Concepts </Tittle>
<Chapter id="1">
This chapter deals with the basics of XML.
<Chapter id="2">
This chapter deals with the basics of DTD.
</Chapter>
</Book>
DTD Program
<!DOCTYPE Book[
<!ELEMENT Book (Tittle,chapter +)>
<!ATTLIST Book Author CDATA #REQUIRED>
<!ELEMENT TITLE(#CDATA)>
<!ELEMENT chapter(#CDATA)>
<!ATTLIST chapter id ID #REQUIRED>
]>
XML name spaces
Name space என்பது element-ல் ஏற்படும் conflict-ஐ avoid செய்ய உதவும் method ஆகும். ஒரே name-ஐ கொண்ட element-ஐ XML document-ல் use செய்யும் போது element name conflict ஏற்படுகிறது.
Example
<Customer>
<Name>IED</Name>
<ID>1001</IED>
<Order>
<Product>
<Name>Pen</Name>
<ID>123</ID>
</Product>
</Order>
<Customer>
இங்கு Name மற்றும் ID element-கள் customer மற்றும் product-ல் use செய்யப்படுகிறது. இதனால் Parser Name மற்றும் ID element-ஐ வேறுபடுத்த முடியாது. இது document-ல் conflict-ஐ ஏற்படுத்தி run ஆகாமல் இருக்கும்.
Name conflict-களை name prefix method-ஐ பயன்படுத்தி avoid பண்ண முடியும்.
Declaring name spaces
Name prefix method-ஐ use செய்து name space-ஐ declare செய்வதற்கான பொதுவடிவம்.
<prefix : elementname xmlns : prefix = "URI">
content
</prefix : elementname>
where
elementname - user define செய்யவும் element-ன் name.
xmlns - attribute
prefix - ஏதேனும் ஒரு character name.
URI - elementname-ன் location-ஐ find செய்ய உதவும் file path.
Example - Consider the XML document given below.
<Customer>
<Name>IED</Name>
<ID> 1001 </ID>
<Order>
<Product>
<Name> Pencil </Name>
</Product>
<Name> pencil </Name>
</Product>
<ID> a 123 </ID>
</Order>
</Customer>
இங்கு name conflict ஏற்படுகிறது ஏனெனில் customer மற்றும் product element-ல் name மற்றும் ID element உள்ளது. இந்த conflict-ஐ avoid செய்ய உதவும் name space கீழே கொடுக்கப்பட்டுள்ளது.
<Customer>
<Cust:Name xmlns: Cust ="CustomernamespaceURI">
IED</Cust:Name>
<Cust:ID xmlns: Cust ="CustomernamespaceURI">
1001</Cust:ID>
<Order>
<Product>
<Proud:Name xmlns: Proud ="productnamespaceURI">
pencil</Proud:Name>
<Proud:ID xmlns: Proud ="productnamespaceURI">
a 123</Proud:ID>
</Order>
</Customer>
By using name space the element name conflict is solved.
Default name Space
Default name space என்பது parent element-ஐ define செய்யும் ஒரு name space ஆகும். எல்லா child element-ம் parent name space-லிருந்து inherit செய்யப்படுகிறது. இதனால் எல்லா child element-ல் prefix bane-ஐ write செய்வதை avoid செய்யலாம். இதன் பொது வடிவம்.
<elementname xmlns="URI">
where
elementname - user define செய்யும் name
xmlns - attribute
URI - கொடுக்கப்படும் element name-ன் location-ஐ find செய்ய உதவும் file path ஆகும்.
Exmple
<Customer xmlns = "customernamespaceURI">
<Name> IED </Name>
<ID> 1001 </ID>
<Order>
<Product xmlns ="productnamespaceURI">
<Name> pencil </Name>
<ID> a123 </ID>
<!ELEMENT Book (Tittle,chapter +)>
<!ATTLIST Book Author CDATA #REQUIRED>
<!ELEMENT TITLE(#CDATA)>
<!ELEMENT chapter(#CDATA)>
<!ATTLIST chapter id ID #REQUIRED>
]>
XML name spaces
Name space என்பது element-ல் ஏற்படும் conflict-ஐ avoid செய்ய உதவும் method ஆகும். ஒரே name-ஐ கொண்ட element-ஐ XML document-ல் use செய்யும் போது element name conflict ஏற்படுகிறது.
Example
<Customer>
<Name>IED</Name>
<ID>1001</IED>
<Order>
<Product>
<Name>Pen</Name>
<ID>123</ID>
</Product>
</Order>
<Customer>
இங்கு Name மற்றும் ID element-கள் customer மற்றும் product-ல் use செய்யப்படுகிறது. இதனால் Parser Name மற்றும் ID element-ஐ வேறுபடுத்த முடியாது. இது document-ல் conflict-ஐ ஏற்படுத்தி run ஆகாமல் இருக்கும்.
Name conflict-களை name prefix method-ஐ பயன்படுத்தி avoid பண்ண முடியும்.
Declaring name spaces
Name prefix method-ஐ use செய்து name space-ஐ declare செய்வதற்கான பொதுவடிவம்.
<prefix : elementname xmlns : prefix = "URI">
content
</prefix : elementname>
where
elementname - user define செய்யவும் element-ன் name.
xmlns - attribute
prefix - ஏதேனும் ஒரு character name.
URI - elementname-ன் location-ஐ find செய்ய உதவும் file path.
Example - Consider the XML document given below.
<Customer>
<Name>IED</Name>
<ID> 1001 </ID>
<Order>
<Product>
<Name> Pencil </Name>
</Product>
<Name> pencil </Name>
</Product>
<ID> a 123 </ID>
</Order>
</Customer>
இங்கு name conflict ஏற்படுகிறது ஏனெனில் customer மற்றும் product element-ல் name மற்றும் ID element உள்ளது. இந்த conflict-ஐ avoid செய்ய உதவும் name space கீழே கொடுக்கப்பட்டுள்ளது.
<Customer>
<Cust:Name xmlns: Cust ="CustomernamespaceURI">
IED</Cust:Name>
<Cust:ID xmlns: Cust ="CustomernamespaceURI">
1001</Cust:ID>
<Order>
<Product>
<Proud:Name xmlns: Proud ="productnamespaceURI">
pencil</Proud:Name>
<Proud:ID xmlns: Proud ="productnamespaceURI">
a 123</Proud:ID>
</Order>
</Customer>
By using name space the element name conflict is solved.
Default name Space
Default name space என்பது parent element-ஐ define செய்யும் ஒரு name space ஆகும். எல்லா child element-ம் parent name space-லிருந்து inherit செய்யப்படுகிறது. இதனால் எல்லா child element-ல் prefix bane-ஐ write செய்வதை avoid செய்யலாம். இதன் பொது வடிவம்.
<elementname xmlns="URI">
where
elementname - user define செய்யும் name
xmlns - attribute
URI - கொடுக்கப்படும் element name-ன் location-ஐ find செய்ய உதவும் file path ஆகும்.
Exmple
<Customer xmlns = "customernamespaceURI">
<Name> IED </Name>
<ID> 1001 </ID>
<Order>
<Product xmlns ="productnamespaceURI">
<Name> pencil </Name>
<ID> a123 </ID>

