SlideShare a Scribd company logo
XMLMukesh N Tekwanitekwani@email.comwww.myexamnotes.com
Disadvantages of HTML – Need for XMLHTML lacks syntax checking
HTML lacks structure
HTML is not suitable for data interchange
HTML is not context aware – HTML does not allow us to describe the information content or the semantics of the document
HTML is not object-oriented
HTML is not re-usable
HTML is not extensibleIntroduction to XMLXML – Extensible Markup Language
Extensible – capable of being extended
Markup – it is a way of adding information to the text indicating the logical components of a document
How is it different from HTML?
HTML was designed to display data
XML was designed to store, describe and transport data
XML is also a markup language like HTML
XML tags are not predefined – we must design our own tags.Differences between HTML and XML
Advantages (Features) of XML - 1XML simplifies data sharingSince XML data is stored in plain text format, data can be easily shared among different hardware and software platforms.XML separates data from HTMLTo display dynamic data in HTML, the code must be rewritten each time the data changes. With XML, data can be stored in separate files so that whenever the data changes it is automatically displayed correctly. We have to design the HTML for layout only once.
Advantages (Features) of XML - 2XML simplifies data transport
With XML, data can be easily exchanged between different platforms.
XML makes data more available
Since XML is independent of hardware, software and application, XML can make your data more available and useful.
Different applications can access your data in HTML pages
XML provides a means to package almost any type of information (binary, text, voice, video) for delivery to a receiving end.Advantages (Features) of XML - 3InternationalityHTML relies heavily on ASCII which makes using foreign characters very difficult. XML uses Unicode so that many European and Asian languages are also handled easily
Applications of XMLFile ConvertersMany applications have been written to convert existing documents into the XML standard. An example is a PDF to XML converter. Cell Phones - XML data is sent to some cell phones. This data is then formatted to display text or images, and even to play sounds!VoiceXML - Converts XML documents into an audio format so that you can listen to an XML document.
XML Document – Example 1<?xml version="1.0" encoding="ISO-8859-1"?><class_list><student><name>Anamika</name><grade>A+</grade></student><student><name>Veena</name><grade>B+</grade></student></class_list>
XML Document–Example 1 - ExplainedThe first line is the XML declaration.
<?xml version="1.0" encoding="ISO-8859-1"?>
It defines the XML version (1.0)
It gives the encoding used (ISO-8859-1 = Latin-1/West European character set)
The XML declaration is actually a processing instruction (PI) an it is identified by the ? At its start and end
The next line describes the root element of the document (like saying: "this document is a class_list“)
The next 2 lines describe 2 child elements of the root (student, name, and grade)
And finally the last line defines the end of the root element: </class_list>Logical StructureXML uses its start tags and end tags as containers.The start tag, the content and the end tag form an elementElements are the building blocks out of which an XML document is assembled.An XML document has a tree-like structure with the root element at the top and all the other elements are contained within each other.
Tree structureXML documents form a tree structure.
XML documents must contain a root element. This element is "the parent" of all other elements.
The elements in an XML document form a document tree. The tree starts at the root and branches to the lowest level of the tree.
All elements can have sub elements (child elements)
<root>	<child>		<subchild>.....</subchild>	</child></rootXML – Example 2
XML – Example 2<bookstore>	<book category = "COOKING">	<title lang = "en">Everyday Italian</title>	<author>Giada De Laurentiis</author>	<year>2005</year>	<price>30.00</price></book>	<book category = "CHILDREN">	<title lang = "en">Harry Potter</title>	<author>J K. Rowling</author>	<year>2005</year>	<price>29.99</price></book>	<book category = "WEB">	<title lang = "en">Learning XML</title>	<author>Erik T. Ray</author>	<year>2003</year>	<price>39.95</price></book></bookstore>
Important DefinitionsXML ElementAn element is a start tag, content, and an end tag.E.g.,  <greeting>”Hello World</greeting> XML AttributeAn attribute provides additional information about elementsE.g., <note priority = “high”>
Important DefinitionsChild elements – XML elements may have child elements<employee id = “100”>	<name>		<first>Anita</first>		<initial>D</initial>		<last>Singh</last>			</name></employee>Parent Element NameChildren of parent element
XML ElementAn XML element is everything from the element's start tag to the element's end tag.An element can contain other elements, simple text or a mixture of both. Elements can also have attributes.
XML Syntax RulesAll XML elements must have a closing tagXML tags are case sensitive. The tag <Book> is different from the tag <book>Opening and closing tags must be written with the same case	<Message>This is incorrect</message><message>This is correct</message>
XML Syntax RulesXML elements must be properly nested
HTML permits this:<B><I>This text is bold and italic</B></I>	But in XML this is invalid. All elements must be properly nested within one another.<B><I>This text is bold and italic</I></B>XML documents must have a root element. It is the parent of all other elements.<root>	<child>	<subchild>.....</subchild></child></root>
XML Syntax RulesXML Entity ReferencesSome characters have a special meaning in XML. E.g., If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element.<message>if salary < 1000 then </message>To avoid this error, replace the "<" character with an entity reference:<message>if salary &lt; 1000 then</message>
XML Syntax RulesXML Entity ReferencesThere are 5 predefined entity references in XML:
XML Syntax RulesComments in XML (similar to HTML)	<!-- This is a comment --> White space is preserved in XML but not in HTML
XML Naming Rules
Names can contain letters, numbers, and other characters
Names cannot start with a number or punctuation character
Names cannot start with the letters xml (or XML, or Xml, etc)
Names cannot contain spaces
Any name can be used, no words are reserved.XML Markup DelimitersEvery XML element is made up of the following parts:		Symbol		Description		<			Start tag open delimiter		</			End tag open delimiter		something		element name		>			tag close delimiter		/>			empty tag close delimiter
Different Types of XML Markups5 Types of Markup in XMLElementsEntitiesCommentsProcessing InstructionsIgnored Sections
Element MarkupElement MarkupIt is composed of 3 parts: start tag, the content, and the end tag.Example:  <name>Neetu</name>The start tag and the end tag can be treated as wrappersThe element name that appears in the start tag must be exactly the same as the name that appears in the end tag.Example:  <Name>Neetu</name>
Different Types of XML MarkupsAttribute MarkupAttributes are used to attach information to the information contained in an element.General syntax for attributes is:<elementname property = ‘value’>			Or<elementname property = “value”>Attribute value must be enclosed within quotation marksUse either single quotes or double quotes but don’t mix them.
Attribute MarkupIf we specify the attributes for the same element more than once, the specifications are merged.<?xml version = “1.0”?><myparas><para num = “first”>This is Para 1 </para><para num = ‘second’ color = “red”>This is Para 2</para><myparas>

More Related Content

What's hot (20)

PPTX
Xml presentation
Miguel Angel Teheran Garcia
 
PPTX
Sgml
rahul kundu
 
PPTX
Xml ppt
seemadav1
 
PPT
introduction to web technology
vikram singh
 
PPT
Html Ppt
vijayanit
 
PPT
Introduction to html
vikasgaur31
 
PPTX
Html ppt
santosh lamba
 
PPT
Xml parsers
Manav Prasad
 
PPTX
Dynamic HTML (DHTML)
Himanshu Kumar
 
PPTX
Css selectors
Parth Trivedi
 
PPT
PHP - Introduction to PHP AJAX
Vibrant Technologies & Computers
 
PPTX
HTML
Akash Varaiya
 
PDF
Introduction to html
eShikshak
 
PPT
Intro Html
Chidanand Byahatti
 
PPT
02 xml schema
Baskarkncet
 
PPTX
Web servers
Kuldeep Kulkarni
 
Xml presentation
Miguel Angel Teheran Garcia
 
Xml ppt
seemadav1
 
introduction to web technology
vikram singh
 
Html Ppt
vijayanit
 
Introduction to html
vikasgaur31
 
Html ppt
santosh lamba
 
Xml parsers
Manav Prasad
 
Dynamic HTML (DHTML)
Himanshu Kumar
 
Css selectors
Parth Trivedi
 
PHP - Introduction to PHP AJAX
Vibrant Technologies & Computers
 
Introduction to html
eShikshak
 
Intro Html
Chidanand Byahatti
 
02 xml schema
Baskarkncet
 
Web servers
Kuldeep Kulkarni
 

Viewers also liked (20)

PPT
Introduction to XML
Jussi Pohjolainen
 
PPT
Introduction to XML
BG Java EE Course
 
PPTX
XML, DTD & XSD Overview
Pradeep Rapolu
 
PPT
Xml
madhavforu
 
PPTX
Introduction to xml
Gtu Booker
 
PPTX
Lecture #2 xml
Adil Alpkoçak
 
PPTX
XML | Computer Science
Transweb Global Inc
 
PPT
XML.ppt
butest
 
PDF
Java API for XML Web Services (JAX-WS)
Peter R. Egli
 
PPT
10. XML in DBMS
koolkampus
 
PPTX
Intro xml
sana mateen
 
PPT
Xml Publisher And Reporting To Excel
Duncan Davies
 
PPTX
Webservices Overview : XML RPC, SOAP and REST
Pradeep Kumar
 
PPT
Xml Session No 1
Saif Ullah Dar
 
PPT
XML - EXtensible Markup Language
Reem Alattas
 
PPT
Dtd
vikram singh
 
PPTX
Basic xml syntax
Raghu nath
 
PPT
Session 1
Lại Đức Chung
 
Introduction to XML
Jussi Pohjolainen
 
Introduction to XML
BG Java EE Course
 
XML, DTD & XSD Overview
Pradeep Rapolu
 
Introduction to xml
Gtu Booker
 
Lecture #2 xml
Adil Alpkoçak
 
XML | Computer Science
Transweb Global Inc
 
XML.ppt
butest
 
Java API for XML Web Services (JAX-WS)
Peter R. Egli
 
10. XML in DBMS
koolkampus
 
Intro xml
sana mateen
 
Xml Publisher And Reporting To Excel
Duncan Davies
 
Webservices Overview : XML RPC, SOAP and REST
Pradeep Kumar
 
Xml Session No 1
Saif Ullah Dar
 
XML - EXtensible Markup Language
Reem Alattas
 
Basic xml syntax
Raghu nath
 
Ad

Similar to XML (20)

DOCX
Introduction to xml
Abhishek Kesharwani
 
DOCX
XML DTD Validate
jomerson remorosa
 
PPT
Xml
Vishwa Mohan
 
PPTX
XML - Extensible Markup Language for Network Security.pptx
kalanamax
 
DOCX
Xml material
prathap kumar
 
DOCX
Xml material
prathap kumar
 
DOCX
Xml material
xavier john
 
PDF
XMLin Web development and Applications.pdf
VinayVitekari
 
PDF
XML for Web Development Information tech.pdf
VinayVitekari
 
PPT
Xml iet 2015
kiransurariya
 
DOCX
Xml 150323102007-conversion-gate01
Niraj Bharambe
 
PPTX
BITM3730Week5.pptx
MattMarino13
 
PPTX
Xml 1
pavishkumarsingh
 
PDF
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
Dr.Florence Dayana
 
PPT
web program-Extended MARKUP Language XML.ppt
mcjaya2024
 
PDF
Xml overview
Haresh Chaudhari
 
PPT
Xml description
sonam gupta
 
Introduction to xml
Abhishek Kesharwani
 
XML DTD Validate
jomerson remorosa
 
XML - Extensible Markup Language for Network Security.pptx
kalanamax
 
Xml material
prathap kumar
 
Xml material
prathap kumar
 
Xml material
xavier john
 
XMLin Web development and Applications.pdf
VinayVitekari
 
XML for Web Development Information tech.pdf
VinayVitekari
 
Xml iet 2015
kiransurariya
 
Xml 150323102007-conversion-gate01
Niraj Bharambe
 
BITM3730Week5.pptx
MattMarino13
 
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
Dr.Florence Dayana
 
web program-Extended MARKUP Language XML.ppt
mcjaya2024
 
Xml overview
Haresh Chaudhari
 
Xml description
sonam gupta
 
Ad

More from Mukesh Tekwani (20)

PDF
The Elphinstonian 1988-College Building Centenary Number (2).pdf
Mukesh Tekwani
 
PPSX
Circular motion
Mukesh Tekwani
 
PPSX
Gravitation
Mukesh Tekwani
 
PDF
ISCE-Class 12-Question Bank - Electrostatics - Physics
Mukesh Tekwani
 
PPTX
Hexadecimal to binary conversion
Mukesh Tekwani
 
PPTX
Hexadecimal to decimal conversion
Mukesh Tekwani
 
PPTX
Hexadecimal to octal conversion
Mukesh Tekwani
 
PPTX
Gray code to binary conversion
Mukesh Tekwani
 
PPTX
What is Gray Code?
Mukesh Tekwani
 
PPSX
Decimal to Binary conversion
Mukesh Tekwani
 
PDF
Video Lectures for IGCSE Physics 2020-21
Mukesh Tekwani
 
PDF
Refraction and dispersion of light through a prism
Mukesh Tekwani
 
PDF
Refraction of light at a plane surface
Mukesh Tekwani
 
PDF
Spherical mirrors
Mukesh Tekwani
 
PDF
Atom, origin of spectra Bohr's theory of hydrogen atom
Mukesh Tekwani
 
PDF
Refraction of light at spherical surfaces of lenses
Mukesh Tekwani
 
PDF
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
Mukesh Tekwani
 
PPSX
Cyber Laws
Mukesh Tekwani
 
PPSX
Social media
Mukesh Tekwani
 
PPSX
TCP-IP Reference Model
Mukesh Tekwani
 
The Elphinstonian 1988-College Building Centenary Number (2).pdf
Mukesh Tekwani
 
Circular motion
Mukesh Tekwani
 
Gravitation
Mukesh Tekwani
 
ISCE-Class 12-Question Bank - Electrostatics - Physics
Mukesh Tekwani
 
Hexadecimal to binary conversion
Mukesh Tekwani
 
Hexadecimal to decimal conversion
Mukesh Tekwani
 
Hexadecimal to octal conversion
Mukesh Tekwani
 
Gray code to binary conversion
Mukesh Tekwani
 
What is Gray Code?
Mukesh Tekwani
 
Decimal to Binary conversion
Mukesh Tekwani
 
Video Lectures for IGCSE Physics 2020-21
Mukesh Tekwani
 
Refraction and dispersion of light through a prism
Mukesh Tekwani
 
Refraction of light at a plane surface
Mukesh Tekwani
 
Spherical mirrors
Mukesh Tekwani
 
Atom, origin of spectra Bohr's theory of hydrogen atom
Mukesh Tekwani
 
Refraction of light at spherical surfaces of lenses
Mukesh Tekwani
 
ISCE (XII) - PHYSICS BOARD EXAM FEB 2020 - WEIGHTAGE
Mukesh Tekwani
 
Cyber Laws
Mukesh Tekwani
 
Social media
Mukesh Tekwani
 
TCP-IP Reference Model
Mukesh Tekwani
 

Recently uploaded (20)

PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPTX
How to Manage Promotions in Odoo 18 Sales
Celine George
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
PPT on the Development of Education in the Victorian England
Beena E S
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
PDF
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
PPTX
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
DOCX
A summary of SPRING SILKWORMS by Mao Dun.docx
maryjosie1
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
How to Manage Promotions in Odoo 18 Sales
Celine George
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Pyhton with Mysql to perform CRUD operations.pptx
Ramakrishna Reddy Bijjam
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
community health nursing question paper 2.pdf
Prince kumar
 
Dimensions of Societal Planning in Commonism
StefanMz
 
PPT on the Development of Education in the Victorian England
Beena E S
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
CHILD RIGHTS AND PROTECTION QUESTION BANK
Dr Raja Mohammed T
 
IMP NAAC REFORMS 2024 - 10 Attributes.pdf
BHARTIWADEKAR
 
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
A summary of SPRING SILKWORMS by Mao Dun.docx
maryjosie1
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 

XML

  • 2. Disadvantages of HTML – Need for XMLHTML lacks syntax checking
  • 4. HTML is not suitable for data interchange
  • 5. HTML is not context aware – HTML does not allow us to describe the information content or the semantics of the document
  • 6. HTML is not object-oriented
  • 7. HTML is not re-usable
  • 8. HTML is not extensibleIntroduction to XMLXML – Extensible Markup Language
  • 9. Extensible – capable of being extended
  • 10. Markup – it is a way of adding information to the text indicating the logical components of a document
  • 11. How is it different from HTML?
  • 12. HTML was designed to display data
  • 13. XML was designed to store, describe and transport data
  • 14. XML is also a markup language like HTML
  • 15. XML tags are not predefined – we must design our own tags.Differences between HTML and XML
  • 16. Advantages (Features) of XML - 1XML simplifies data sharingSince XML data is stored in plain text format, data can be easily shared among different hardware and software platforms.XML separates data from HTMLTo display dynamic data in HTML, the code must be rewritten each time the data changes. With XML, data can be stored in separate files so that whenever the data changes it is automatically displayed correctly. We have to design the HTML for layout only once.
  • 17. Advantages (Features) of XML - 2XML simplifies data transport
  • 18. With XML, data can be easily exchanged between different platforms.
  • 19. XML makes data more available
  • 20. Since XML is independent of hardware, software and application, XML can make your data more available and useful.
  • 21. Different applications can access your data in HTML pages
  • 22. XML provides a means to package almost any type of information (binary, text, voice, video) for delivery to a receiving end.Advantages (Features) of XML - 3InternationalityHTML relies heavily on ASCII which makes using foreign characters very difficult. XML uses Unicode so that many European and Asian languages are also handled easily
  • 23. Applications of XMLFile ConvertersMany applications have been written to convert existing documents into the XML standard. An example is a PDF to XML converter. Cell Phones - XML data is sent to some cell phones. This data is then formatted to display text or images, and even to play sounds!VoiceXML - Converts XML documents into an audio format so that you can listen to an XML document.
  • 24. XML Document – Example 1<?xml version="1.0" encoding="ISO-8859-1"?><class_list><student><name>Anamika</name><grade>A+</grade></student><student><name>Veena</name><grade>B+</grade></student></class_list>
  • 25. XML Document–Example 1 - ExplainedThe first line is the XML declaration.
  • 27. It defines the XML version (1.0)
  • 28. It gives the encoding used (ISO-8859-1 = Latin-1/West European character set)
  • 29. The XML declaration is actually a processing instruction (PI) an it is identified by the ? At its start and end
  • 30. The next line describes the root element of the document (like saying: "this document is a class_list“)
  • 31. The next 2 lines describe 2 child elements of the root (student, name, and grade)
  • 32. And finally the last line defines the end of the root element: </class_list>Logical StructureXML uses its start tags and end tags as containers.The start tag, the content and the end tag form an elementElements are the building blocks out of which an XML document is assembled.An XML document has a tree-like structure with the root element at the top and all the other elements are contained within each other.
  • 33. Tree structureXML documents form a tree structure.
  • 34. XML documents must contain a root element. This element is "the parent" of all other elements.
  • 35. The elements in an XML document form a document tree. The tree starts at the root and branches to the lowest level of the tree.
  • 36. All elements can have sub elements (child elements)
  • 38. XML – Example 2<bookstore> <book category = "COOKING"> <title lang = "en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price></book> <book category = "CHILDREN"> <title lang = "en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price></book> <book category = "WEB"> <title lang = "en">Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price></book></bookstore>
  • 39. Important DefinitionsXML ElementAn element is a start tag, content, and an end tag.E.g., <greeting>”Hello World</greeting> XML AttributeAn attribute provides additional information about elementsE.g., <note priority = “high”>
  • 40. Important DefinitionsChild elements – XML elements may have child elements<employee id = “100”> <name> <first>Anita</first> <initial>D</initial> <last>Singh</last> </name></employee>Parent Element NameChildren of parent element
  • 41. XML ElementAn XML element is everything from the element's start tag to the element's end tag.An element can contain other elements, simple text or a mixture of both. Elements can also have attributes.
  • 42. XML Syntax RulesAll XML elements must have a closing tagXML tags are case sensitive. The tag <Book> is different from the tag <book>Opening and closing tags must be written with the same case <Message>This is incorrect</message><message>This is correct</message>
  • 43. XML Syntax RulesXML elements must be properly nested
  • 44. HTML permits this:<B><I>This text is bold and italic</B></I> But in XML this is invalid. All elements must be properly nested within one another.<B><I>This text is bold and italic</I></B>XML documents must have a root element. It is the parent of all other elements.<root> <child> <subchild>.....</subchild></child></root>
  • 45. XML Syntax RulesXML Entity ReferencesSome characters have a special meaning in XML. E.g., If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element.<message>if salary < 1000 then </message>To avoid this error, replace the "<" character with an entity reference:<message>if salary &lt; 1000 then</message>
  • 46. XML Syntax RulesXML Entity ReferencesThere are 5 predefined entity references in XML:
  • 47. XML Syntax RulesComments in XML (similar to HTML) <!-- This is a comment --> White space is preserved in XML but not in HTML
  • 49. Names can contain letters, numbers, and other characters
  • 50. Names cannot start with a number or punctuation character
  • 51. Names cannot start with the letters xml (or XML, or Xml, etc)
  • 53. Any name can be used, no words are reserved.XML Markup DelimitersEvery XML element is made up of the following parts: Symbol Description < Start tag open delimiter </ End tag open delimiter something element name > tag close delimiter /> empty tag close delimiter
  • 54. Different Types of XML Markups5 Types of Markup in XMLElementsEntitiesCommentsProcessing InstructionsIgnored Sections
  • 55. Element MarkupElement MarkupIt is composed of 3 parts: start tag, the content, and the end tag.Example: <name>Neetu</name>The start tag and the end tag can be treated as wrappersThe element name that appears in the start tag must be exactly the same as the name that appears in the end tag.Example: <Name>Neetu</name>
  • 56. Different Types of XML MarkupsAttribute MarkupAttributes are used to attach information to the information contained in an element.General syntax for attributes is:<elementname property = ‘value’> Or<elementname property = “value”>Attribute value must be enclosed within quotation marksUse either single quotes or double quotes but don’t mix them.
  • 57. Attribute MarkupIf we specify the attributes for the same element more than once, the specifications are merged.<?xml version = “1.0”?><myparas><para num = “first”>This is Para 1 </para><para num = ‘second’ color = “red”>This is Para 2</para><myparas>
  • 58. Attribute MarkupWhen the XML processor encounters line 3, it will record the fact that para element has the num attributeWhen it encounters the 4th line it will record the fact that para element has the color attribute
  • 59. Reserved AttributeThe xml:lang attribute is reserved to identify the human language in which the element was writtenThe value of attribute is one of the following:en Englishfr Frenchde German
  • 60. XML AttributesAttribute provides additional information about the element
  • 61. Similar to attributes in HTML e.g., <IMG SRC=“sky.jpg”> In this SRC is the attribute
  • 62. XML Attribute values must be quoted
  • 63. XML elements can have attributes in name/value pairs just like in HTML.
  • 64. In XML the attribute value must always be quoted.<note date = 01/01/2010> <---------- This is invalid<to>Priya</to><from>Deeali</from></note><note date = “01/01/2010”> --------- Now OK since enclosed in double quotes<note date = ‘01/01/2010’> --------- This is also OK since enclosed in single quotes
  • 65. XML Attributes and ElementsConsider the following example:<person gender = "female"> <firstname>Geeta</firstname> <lastname>Shah</lastname></person>Gender is an attributeGender is an element<person> <gender>female</gender> <firstname>Geeta</firstname> <lastname>Shah</lastname></person>
  • 66. Problems with XML AttributesAttributes cannot contain multiple values whereas elements can
  • 67. Attributes cannot contain tree structures
  • 68. Attributes are not easily expandable (for future changes)
  • 69. Attributes are difficult to read and maintain
  • 71. Use attributes for information that is not relevant to the data.Illustrating Problematic AttributesConsider the following example: <note day=“03" month="02" year="2010"to="Tina" from=“Yasmin" heading="Reminder"body=“Happy Birthday!"></note>Better way: <note> <date> <day>03</day> <month>02</month> <year>2010</year> </date> <to>Tina</to> <from>Yasmin</from> <heading>Reminder</heading> <body>Happy Birthday!</body></note>
  • 72. When to use Attributes?XML Attributes can be used to assign ID references to elements.
  • 73. Metadata – data about data – should be stored as attributes
  • 74. The ID can then be used to identify the XML element <messages><note id="501"> <to>Tina</to> <from>Yasmin</from> <heading>Reminder</heading> <body>Happy Birthday!</body></note><note id="502"> <to>Yasmin</to> <from>Tina</from> <heading>Re: Reminder</heading> <body>Thank you, my dear</body></note></messages>
  • 75. What does Extensible mean in XML?Consider the following XML example: <note> <to>Anita</to> <from>Veena</from> <body>You have an exam tomorrow</body></note> Suppose we create an application that extracted the <to>, <from> and <body> elements from the XML document to produce the result: MESSAGE To: AnitaFrom:Veena You have an exam tomorrow
  • 76. What does Extensible mean in XML?Now suppose the author of the XML document added some extra information to it:<note><date>2008-01-10</date><to>Anita</to><from>Veena</from><heading>Reminder</heading><body>You have an exam tomorrow</body></note>
  • 77. What does Extensible mean in XML?This application will not crash because it will still find the <to>, <from> and <body> elements in the XML document and produce the same output.
  • 78. XML ValidationWhat is a “well formed” XML document?XML with correct syntax is "Well Formed" XML.A "Well Formed" XML document has correct XML syntax.XML documents must have a root elementXML elements must have a closing tagXML tags are case sensitiveXML elements must be properly nestedXML attribute values must be quoted
  • 79. Wellformed Document - Rule 1Elements are case-sensitive.
  • 80. If you define you language to use lowercase elements, then all instances of those elements must be in lowercase.Bad Examples…<H1>Sample Heading</H1><h1>Sample Heading</H1><H1>Sample Heading</h1>
  • 81. Rule 2:All elements that contain text or other elements must have both start and ending tags.Rule 3:All empty elements (commonly known as standalone tags) must have a slash (/) before the end of the tag.Rule 4:All attribute values must be contained in quotes, either single or double – no exceptions!Rule 5:Elements may not overlap.
  • 82. Elements must be nested properly within other elements and can not start before a sub-element and end within the sub-element. Rule 6:Isolated markup characters (characters essential to creating markup documents) may not appear in parsed content as is.
  • 83. Isolated markup characters must be represented as a character entity and include the following: <, [, ], >, ', " and &.Isolated Markup Characters
  • 84. These examples are invalid since they are both examples forgetting the semi-colon following the character entity.Bad Examples…<h1>Jack &amp Jill</h1><equation>5 &lt 2</equation>
  • 85. Good Examples…<h1>Jack &amp; Jill</h1><equation>5 &lt; 2</equation>
  • 86. Rule 7:Element (and attribute) names must start with either a letter (uppercase or lowercase) or a underscore.
  • 87. Element names may contain letters, numbers, hyphens, periods and underscores inclusively.BAD EXAMPLES<bad*characters><illegal space><99number-start>GOOD EXAMPLES<example-one><_example2><Example.Three>
  • 88. XML ValidationA “well formed” XML document conforms to the rules of a Document Type Definition (DTD) <?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE note SYSTEM "Note.dtd"><note> <to>Tina</to> <from>Yasmin</from> <heading>Reminder</heading> <body>Happy Birthday!</body></note>
  • 89. XML DTD – Document Type DefinitionThe DOCTYPE declaration in the example above, is a reference to an external DTD file. The content of the file is shown in the paragraph below.
  • 90. The purpose of a DTD is to define the structure of an XML document. It defines the structure with a list of legal elements: <!DOCTYPE note[ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)>]>More on DOCTYPE laterViewing XML Files - 1
  • 91. Viewing XML Files - 2The XML document will be displayed with color-coded root and child elements. A plus (+) or minus sign (-) to the left of the elements can be clicked to expand or collapse the element structure. To view the raw XML source (without the + and - signs), select "View Page Source" or "View Source" from the browser menu.
  • 92. Viewing XML Files - 3Why XML documents display like this?XML documents do not carry information about how to display the data.Since XML tags are created by the user of the XML document, browsers do not know if a tag like <table> describes an HTML table or a dining table.Without any information about how to display the data, most browsers will just display the XML document as it is.
  • 93. Using CSS to display XML FilesCSS (Cascading Style Sheets) can be used to format a XML document.Consider this XML document:
  • 94. Displaying Formatted XML document-1<?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type = "text/css" href = "birthdate.css"?><birthdate> <person> <name> <first>Anokhi</first> <last>Parikh</last> </name> <date> <month>01</month> <day>21</day> <year>1992</year> </date> </person></birthdate>
  • 95. Displaying Formatted XML document-2Stylesheet – birthdate.cssbirthdate{ background-color: #ffffff; width: 100%;}person{ margin-left: 0;}name{ color: #FF0000; font-size: 20pt;}month, day, year{display:block; color: #000000; margin-left: 20pt;}
  • 97. XSLTXSL is a language for style sheets
  • 98. An XSL style sheet is a file that describes how to display an XML document
  • 99. XSL contains a transformation language for XML documents: XSLT. XSLT is used for generating HTML web pages from XML data.
  • 101. XSLT is used to transform an XML document into an HTML document
  • 102. XSLT is the recommended style sheet language for XML