SlideShare a Scribd company logo
1 of 51
Excellence and
Service
CHRIST
Deemed to be University
Extensible Markup
Language (XML)
1
MISSION
CHRIST is a nurturing ground for an individual’s
holistic development to make effective contribution to
the society in a dynamic environment
VISION
Excellence and Service
CORE VALUES
Faith in God | Moral Uprightness
Love of Fellow Beings
Social Responsibility | Pursuit of Excellence
Excellence and
Service
CHRIST
Deemed to be University
What is XML
• XML stands for eXtensible Markup Language.
• A markup language is used to provide
information about a document.
• Tags are added to the document to provide the
extra information.
• HTML tags tell a browser how to display the
document.
• XML tags give a reader some idea what some of
the data means.
Excellence and
Service
CHRIST
Deemed to be University
What is XML Used For?
• XML documents are used to transfer data from one place
to another often over the Internet.
• XML subsets are designed for particular applications.
• One is RSS (Rich Site Summary or Really Simple
Syndication ). It is used to send breaking news bulletins
from one web site to another.
• A number of fields have their own subsets. These
include chemistry, mathematics, and books publishing.
• Most of these subsets are registered with the
W3Consortium and are available for anyone’s use.
Excellence and
Service
CHRIST
Deemed to be University
Advantages of XML
• XML is text (Unicode) based.
– Takes up less space.
– Can be transmitted efficiently.
• One XML document can be displayed differently
in different media.
– Html, video, CD, DVD,
– You only have to change the XML document in order
to change all the rest.
• XML documents can be modularized. Parts can
be reused.
Excellence and
Service
CHRIST
Deemed to be University
Adv. of XML Cntd…
• Structured language
• Platform Independent
• Open Standard
• Language Independent
• Web Enabled
• Extensible
Excellence and
Service
CHRIST
Deemed to be University
Example of an HTML Document
<html>
<head><title>Example</title></head.
<body>
<h1>This is an example of a page.</h1>
<h2>Some information goes here.</h2>
</body>
</html>
Excellence and
Service
CHRIST
Deemed to be University
Example of an XML Document
<?xml version=“1.0”/>
<address>
<name>Alice Lee</name>
<email>alee@aol.com</email>
<phone>212-346-1234</phone>
<birthday>1985-03-22</birthday>
</address>
Excellence and
Service
CHRIST
Deemed to be University
Difference Between HTML and XML
• HTML tags have a fixed meaning and
browsers know what it is.
• XML tags are different for different
applications, and users know what they
mean.
• HTML tags are used for display.
• XML tags are used to describe documents
and data.
Excellence and
Service
CHRIST
Deemed to be University
HTML vs XML
Excellence and
Service
CHRIST
Deemed to be University
XML vs HTML
• XML HTML
 Describes Data and focusses
on what data is
 Support Case – sensitivity
User defined Language
Mandatory to close all tags
Enclose attribute values in “”
Excellence and
Service
CHRIST
Deemed to be University
Advantage in XML
• Stores data in the form of plain text
• Provides a basic syntax to share the info.
With different applications
• No restriction on tags
• Web standards
Excellence and
Service
CHRIST
Deemed to be University
Disadvantages in XML
• Represents redundant and similar syntax
for binary data
• Does not support intrinsic data (data
types)
• Requires a processing application
• Requires XML specific browsers.
Excellence and
Service
CHRIST
Deemed to be University
XML Rules
• Tags are enclosed in angle brackets.
• Elements come in pairs with start-tags and
end-tags.
• Tags must be properly nested.
– <name><email>…</name></email> is not allowed.
– <name><email>…</email><name> is allowed.
• Tags that do not have end-tags must be
terminated by a ‘/’.
– <br /> is an html example.
Excellence and
Service
CHRIST
Deemed to be University
More XML Rules
• Tags are case sensitive.
– <address> is not the same as <Address>
• XML in any combination of cases is not allowed
as part of a tag.
• Tags may not contain ‘<‘ or ‘&’.
• Tags follow Java naming conventions, except
that a single colon and other characters are
allowed. They must begin with a letter and may
not contain white space.
• Documents must have a single root tag that
begins the document.
Excellence and
Service
CHRIST
Deemed to be University
Encoding
• XML (like Java) uses Unicode to encode characters.
• Unicode comes in many flavors. The most common one
used in the West is UTF-8.
• UTF-8 is a variable length code. Characters are
encoded in 1 byte, 2 bytes, or 4 bytes.
• The first 128 characters in Unicode are ASCII.
• In UTF-8, the numbers between 128 and 255 code for
some of the more common characters used in western
Europe, such as ã, á, å, or ç.
• Two byte codes are used for some characters not listed
in the first 256 and some Asian ideographs.
• Four byte codes can handle any ideographs that are left.
• Those using non-western languages should investigate
other versions of Unicode.
Excellence and
Service
CHRIST
Deemed to be University
Well-Formed Documents
• An XML document is said to be well-formed if it
follows all the rules.
• An XML parser is used to check that all the rules
have been obeyed.
• Recent browsers such as Internet Explorer 5
and Netscape 7 come with XML parsers.
• Parsers are also available for free download
over the Internet. One is Xerces, from the
Apache open-source project.
• Java 1.4 also supports an open-source parser.
Excellence and
Service
CHRIST
Deemed to be University
XML Structure
• XML Declaration
• XML Elements
• XML Attributes
• XML tree
• XML Comments
Excellence and
Service
CHRIST
Deemed to be University
XML Declaration
• <?XML version=“1.0” encoding=“ISO-
8859-1” standalone=“yes”?>
- Version – Mandatory
- Encoding – Character encoding - optional
- Standalone – Internal DTD / no – Optional
Excellence and
Service
CHRIST
Deemed to be University
XML Elements
• Start tag and end tag <element>
</element>
• Root element /document element
• Empty elements <item ir=“er” />
• Nested elements <item>
<Product>
</Product>
</item>
Excellence and
Service
CHRIST
Deemed to be University
XML Attributes
• Additional info.
• <Employee>
<person gender=“male” color=“brown”>
king mathur
</person>
</Employee>
* XML Comments – same as HTML
Excellence and
Service
CHRIST
Deemed to be University
XML Example Revisited
<?xml version=“1.0”/>
<address>
<name>Alice Lee</name>
<email>alee@aol.com</email>
<phone>212-346-1234</phone>
<birthday>1985-03-22</birthday>
</address>
• Markup for the data aids understanding of its purpose.
• A flat text file is not nearly so clear.
Alice Lee
alee@aol.com
212-346-1234
1985-03-22
Excellence and
Service
CHRIST
Deemed to be University
Expanded Example
<?xml version = “1.0” ?>
<address>
<name>
<first>Alice</first>
<last>Lee</last>
</name>
<email>alee@aol.com</email>
<phone>123-45-6789</phone>
<birthday>
<year>1983</year>
<month>07</month>
<day>15</day>
</birthday>
</address>
Excellence and
Service
CHRIST
Deemed to be University
XML Tree
Excellence and
Service
CHRIST
Deemed to be University
XML Files are Trees
address
name email phone birthday
first last year month day
Excellence and
Service
CHRIST
Deemed to be University
XML Trees
• An XML document has a single root node.
• The tree is a general ordered tree.
– A parent node may have any number of
children.
– Child nodes are ordered, and may have
siblings.
• Preorder traversals are usually used for
getting information out of the tree.
Excellence and
Service
CHRIST
Deemed to be University
Validity
• A well-formed document has a tree structure and
obeys all the XML rules.
• A particular application may add more rules in
either a DTD (document type definition) or in a
schema.
• Many specialized DTDs and schemas have
been created to describe particular areas.
• These range from disseminating news bulletins
(RSS) to chemical formulas.
• DTDs were developed first, so they are not as
comprehensive as schema.
Excellence and
Service
CHRIST
Deemed to be University
XML Entity References
• Chars used for constructing tags
• &lt - <
• &gt - >
• &amp - &
• &quot - “”
• &apos – ‘
Excellence and
Service
CHRIST
Deemed to be University
XML Parser
• Non validating parser – validates XML not
DTD
• Validating Parser – Validates both
• Eg., expat, SAXI (simple Api for XML),
Xerces, MSXML
Excellence and
Service
CHRIST
Deemed to be University
XML Parser
Excellence and
Service
CHRIST
Deemed to be University
QUIZ TIME
• https://www.w3schools.com/
quiztest/quiztest.asp?qtest=
XML
Excellence and
Service
CHRIST
Deemed to be University
Document Type Definitions(DTD)
• A DTD describes the tree structure of a
document and something about its data.
• Validate the XML
• There are two data types, PCDATA and
CDATA.
– PCDATA is parsed character data.
– CDATA is character data, not usually parsed.
• A DTD determines how many times a
node may appear, and how child nodes
are ordered.
Excellence and
Service
CHRIST
Deemed to be University
DTD for address Example
<!ELEMENT address (name, email, phone, birthday)>
<!ELEMENT name (first, last)>
<!ELEMENT first (#PCDATA)>
<!ELEMENT last (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT birthday (year, month, day)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT month (#PCDATA)>
<!ELEMENT day (#PCDATA)>
Excellence and
Service
CHRIST
Deemed to be University
Declaration of DTD
• Internal eg. internaldtd.xml
• External eg. Drink.xml drink.dtd
Excellence and
Service
CHRIST
Deemed to be University
DTD declaration
• DTD for single element
• DTD for nested elements
• Defining Attributes in DTD
• Defining entities in DTD
• Referencing External entities
Excellence and
Service
CHRIST
Deemed to be University
DTD for single element
• DTD for a single element, which does not
contain any text or other element
• <?xml version=“1.0” encoding=“UTF-8”?>
<!ELEMENT
PRODUCTDATA(PRODUCT+)
• ? - Applies to 0 or 1 element
• * - Applies to 0 or more elements
• + - Applies to one or more elements
Excellence and
Service
CHRIST
Deemed to be University
DTD for nested elements
<!ELEMENT
PRODUCTDATA(PRODUCT+)>
<!ELEMENT PRODUCT (PRODUCTNAME,
DESCRIPTION)>
<!ELEMENT PRODUCTNAME(#PCDATA)>
<!ELEMENT DESCRIPTION(#PCDATA)>
<!ELEMENT item (#PCDATA | item)*>
Excellence and
Service
CHRIST
Deemed to be University
Defining Attributes in DTD
• <!ATTLIST element-name attribute-name attribute-type default-
value>
• <!ATTLIST salary type CDATA “check”>
• Attribute type desc
(values | value|..) Values sep. by |
CDATA Unparsed data
ENTITIES
ENTITY
ID
IDREF
IDREFS
NMTOKEN
NMTOKENS
NOTATION
Excellence and
Service
CHRIST
Deemed to be University
Default Values
• Value Description
value default value for the attribute
#REQUIRED Compulsory
#IMPLIED Not Compulsory
# FIXED value Fixed value for the
attribute
Excellence and
Service
CHRIST
Deemed to be University
Defining entities in DTD
• Shortcuts that can be replaced by
completed definition
<!ENTITY entity-name SYSTEM “URI/URL”>
<!ENTITY entity-name “entity definition”>
EG.
<!ENTITY writer “Ken Thompson”>
<!ENTITY copyright “Christ 2019”>
<author > &writer;&copyright;</author>
Excellence and
Service
CHRIST
Deemed to be University
Referencing External entities
• SYSTEM / PUBLIC identifier
<!DOCTYPE books SYSTEM “books.dtd” [
<!ENTITY writer “Ken Thompson”>
<!ENTITY copyright SYSTEM
“COPYRIGHT.XML”>
]>
<author > &writer;&copyright;</author>
Excellence and
Service
CHRIST
Deemed to be University
XML Namespaces
• URI – uniqueness to the names of elements and
attributes of the XML documents.
• Combine the different elements/attributes
• (same name??) / conflict
• NAME PREFIX TO THE ELEMENT
• <n:table>
• Xmlns: prefix=“URI”
Chap. 29
Excellence and
Service
CHRIST
Deemed to be University
Schemas
• Defines the structure of a XML document
• Schemas are themselves XML documents.
• Validate the structure of a XML file by parser.
• Standardized after DTDs and provide more
information about the document by XML
Schema Document (XSD).
• Number of data types including string, decimal,
integer, boolean, date, and time.
• Divide elements into simple and complex types.
• Determine the tree structure and how many
children a node may have.
Excellence and
Service
CHRIST
Deemed to be University
DTD vs SCHEMA
DTD Schema
• elements, attributes structure of the
and entities element with data type
• No namespaces
• XML syntax not followed
• Strong Typing simple and complex
data types
Excellence and
Service
CHRIST
Deemed to be University
Schema definition
<xs:element name=“name” type=“type”/>
Data types:
xs_string
xs_date
xs_numeric
xs_misc
Types:
Simple - text
Complex - child elements and attributes
Excellence and
Service
CHRIST
Deemed to be University
Schema for First address Example
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="address">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="email" type="xs:string"/>
<xs:element name="phone" type="xs:string"/>
<xs:element name="birthday" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Eg.
Excellence and
Service
CHRIST
Deemed to be University
Explanation of Example Schema
<?xml version="1.0" encoding="ISO-8859-1" ?>
• ISO-8859-1, Latin-1, is the same as UTF-8 in the first 128 characters.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
• www.w3.org/2001/XMLSchema contains the schema standards.
<xs:element name="address">
<xs:complexType>
• This states that address is a complex type element.
<xs:sequence>
• This states that the following elements form a sequence and must
come in the order shown.
<xs:element name="name" type="xs:string"/>
• This says that the element, name, must be a string.
<xs:element name="birthday" type="xs:date"/>
• This states that the element, birthday, is a date. Dates are always of
the form yyyy-mm-dd.
Excellence and
Service
CHRIST
Deemed to be University
XSLT
Extensible Stylesheet Language Transformations
• XSLT is used to transform one xml document
into another, often an html document.
• The Transform classes are now part of Java 1.4.
• A program is used that takes as input one xml
document and produces as output another.
• If the resulting document is in html, it can be
viewed by a web browser.
• This is a good way to display xml data.
Excellence and
Service
CHRIST
Deemed to be University
A Style Sheet to Transform address.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="address">
<html><head><title>Address Book</title></head>
<body>
<xsl:value-of select="name"/>
<br/><xsl:value-of select="email"/>
<br/><xsl:value-of select="phone"/>
<br/><xsl:value-of select="birthday"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Excellence and
Service
CHRIST
Deemed to be University
The Result of the Transformation
Alice Lee
alee@aol.com
123-45-6789
1983-7-15
Excellence and
Service
CHRIST
Deemed to be University
Parsers
• There are two principal models for
parsers.
• SAX – Simple API for XML
– Uses a call-back method
– Similar to javax listeners
• DOM – Document Object Model
– Creates a parse tree
– Requires a tree traversal
Excellence and
Service
CHRIST
Deemed to be University
References
• Elliotte Rusty Harold, Processing XML with
Java, Addison Wesley, 2002.
• Elliotte Rusty Harold and Scott Means,
XML Programming, O’Reilly & Associates,
Inc., 2002.
• W3Schools Online Web Tutorials,
http://www.w3schools.com.

More Related Content

Similar to msc_xml1.ppt (20)

XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
Xml basics
Xml basicsXml basics
Xml basics
 
Xml
XmlXml
Xml
 
Xml passing in java
Xml passing in javaXml passing in java
Xml passing in java
 
xml
xmlxml
xml
 
Extensible Markup Language (XML)
Extensible Markup Language (XML)Extensible Markup Language (XML)
Extensible Markup Language (XML)
 
00 introduction
00 introduction00 introduction
00 introduction
 
BITM3730 10-31.pptx
BITM3730 10-31.pptxBITM3730 10-31.pptx
BITM3730 10-31.pptx
 
BITM3730 10-18.pptx
BITM3730 10-18.pptxBITM3730 10-18.pptx
BITM3730 10-18.pptx
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
XML
XMLXML
XML
 
E-publishing
E-publishingE-publishing
E-publishing
 
XML.pptx
XML.pptxXML.pptx
XML.pptx
 
XML
XMLXML
XML
 
Xml
XmlXml
Xml
 
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5   XMLM.FLORENCE DAYANA WEB DESIGN -Unit 5   XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
 
Unit iv xml dom
Unit iv xml domUnit iv xml dom
Unit iv xml dom
 
Data interchange integration, HTML XML Biological XML DTD
Data interchange integration, HTML XML Biological XML DTDData interchange integration, HTML XML Biological XML DTD
Data interchange integration, HTML XML Biological XML DTD
 
XML
XMLXML
XML
 
Ch2 neworder
Ch2 neworderCh2 neworder
Ch2 neworder
 

Recently uploaded

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Recently uploaded (20)

Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

msc_xml1.ppt

  • 1. Excellence and Service CHRIST Deemed to be University Extensible Markup Language (XML) 1 MISSION CHRIST is a nurturing ground for an individual’s holistic development to make effective contribution to the society in a dynamic environment VISION Excellence and Service CORE VALUES Faith in God | Moral Uprightness Love of Fellow Beings Social Responsibility | Pursuit of Excellence
  • 2. Excellence and Service CHRIST Deemed to be University What is XML • XML stands for eXtensible Markup Language. • A markup language is used to provide information about a document. • Tags are added to the document to provide the extra information. • HTML tags tell a browser how to display the document. • XML tags give a reader some idea what some of the data means.
  • 3. Excellence and Service CHRIST Deemed to be University What is XML Used For? • XML documents are used to transfer data from one place to another often over the Internet. • XML subsets are designed for particular applications. • One is RSS (Rich Site Summary or Really Simple Syndication ). It is used to send breaking news bulletins from one web site to another. • A number of fields have their own subsets. These include chemistry, mathematics, and books publishing. • Most of these subsets are registered with the W3Consortium and are available for anyone’s use.
  • 4. Excellence and Service CHRIST Deemed to be University Advantages of XML • XML is text (Unicode) based. – Takes up less space. – Can be transmitted efficiently. • One XML document can be displayed differently in different media. – Html, video, CD, DVD, – You only have to change the XML document in order to change all the rest. • XML documents can be modularized. Parts can be reused.
  • 5. Excellence and Service CHRIST Deemed to be University Adv. of XML Cntd… • Structured language • Platform Independent • Open Standard • Language Independent • Web Enabled • Extensible
  • 6. Excellence and Service CHRIST Deemed to be University Example of an HTML Document <html> <head><title>Example</title></head. <body> <h1>This is an example of a page.</h1> <h2>Some information goes here.</h2> </body> </html>
  • 7. Excellence and Service CHRIST Deemed to be University Example of an XML Document <?xml version=“1.0”/> <address> <name>Alice Lee</name> <email>alee@aol.com</email> <phone>212-346-1234</phone> <birthday>1985-03-22</birthday> </address>
  • 8. Excellence and Service CHRIST Deemed to be University Difference Between HTML and XML • HTML tags have a fixed meaning and browsers know what it is. • XML tags are different for different applications, and users know what they mean. • HTML tags are used for display. • XML tags are used to describe documents and data.
  • 9. Excellence and Service CHRIST Deemed to be University HTML vs XML
  • 10. Excellence and Service CHRIST Deemed to be University XML vs HTML • XML HTML  Describes Data and focusses on what data is  Support Case – sensitivity User defined Language Mandatory to close all tags Enclose attribute values in “”
  • 11. Excellence and Service CHRIST Deemed to be University Advantage in XML • Stores data in the form of plain text • Provides a basic syntax to share the info. With different applications • No restriction on tags • Web standards
  • 12. Excellence and Service CHRIST Deemed to be University Disadvantages in XML • Represents redundant and similar syntax for binary data • Does not support intrinsic data (data types) • Requires a processing application • Requires XML specific browsers.
  • 13. Excellence and Service CHRIST Deemed to be University XML Rules • Tags are enclosed in angle brackets. • Elements come in pairs with start-tags and end-tags. • Tags must be properly nested. – <name><email>…</name></email> is not allowed. – <name><email>…</email><name> is allowed. • Tags that do not have end-tags must be terminated by a ‘/’. – <br /> is an html example.
  • 14. Excellence and Service CHRIST Deemed to be University More XML Rules • Tags are case sensitive. – <address> is not the same as <Address> • XML in any combination of cases is not allowed as part of a tag. • Tags may not contain ‘<‘ or ‘&’. • Tags follow Java naming conventions, except that a single colon and other characters are allowed. They must begin with a letter and may not contain white space. • Documents must have a single root tag that begins the document.
  • 15. Excellence and Service CHRIST Deemed to be University Encoding • XML (like Java) uses Unicode to encode characters. • Unicode comes in many flavors. The most common one used in the West is UTF-8. • UTF-8 is a variable length code. Characters are encoded in 1 byte, 2 bytes, or 4 bytes. • The first 128 characters in Unicode are ASCII. • In UTF-8, the numbers between 128 and 255 code for some of the more common characters used in western Europe, such as ã, á, å, or ç. • Two byte codes are used for some characters not listed in the first 256 and some Asian ideographs. • Four byte codes can handle any ideographs that are left. • Those using non-western languages should investigate other versions of Unicode.
  • 16. Excellence and Service CHRIST Deemed to be University Well-Formed Documents • An XML document is said to be well-formed if it follows all the rules. • An XML parser is used to check that all the rules have been obeyed. • Recent browsers such as Internet Explorer 5 and Netscape 7 come with XML parsers. • Parsers are also available for free download over the Internet. One is Xerces, from the Apache open-source project. • Java 1.4 also supports an open-source parser.
  • 17. Excellence and Service CHRIST Deemed to be University XML Structure • XML Declaration • XML Elements • XML Attributes • XML tree • XML Comments
  • 18. Excellence and Service CHRIST Deemed to be University XML Declaration • <?XML version=“1.0” encoding=“ISO- 8859-1” standalone=“yes”?> - Version – Mandatory - Encoding – Character encoding - optional - Standalone – Internal DTD / no – Optional
  • 19. Excellence and Service CHRIST Deemed to be University XML Elements • Start tag and end tag <element> </element> • Root element /document element • Empty elements <item ir=“er” /> • Nested elements <item> <Product> </Product> </item>
  • 20. Excellence and Service CHRIST Deemed to be University XML Attributes • Additional info. • <Employee> <person gender=“male” color=“brown”> king mathur </person> </Employee> * XML Comments – same as HTML
  • 21. Excellence and Service CHRIST Deemed to be University XML Example Revisited <?xml version=“1.0”/> <address> <name>Alice Lee</name> <email>alee@aol.com</email> <phone>212-346-1234</phone> <birthday>1985-03-22</birthday> </address> • Markup for the data aids understanding of its purpose. • A flat text file is not nearly so clear. Alice Lee alee@aol.com 212-346-1234 1985-03-22
  • 22. Excellence and Service CHRIST Deemed to be University Expanded Example <?xml version = “1.0” ?> <address> <name> <first>Alice</first> <last>Lee</last> </name> <email>alee@aol.com</email> <phone>123-45-6789</phone> <birthday> <year>1983</year> <month>07</month> <day>15</day> </birthday> </address>
  • 23. Excellence and Service CHRIST Deemed to be University XML Tree
  • 24. Excellence and Service CHRIST Deemed to be University XML Files are Trees address name email phone birthday first last year month day
  • 25. Excellence and Service CHRIST Deemed to be University XML Trees • An XML document has a single root node. • The tree is a general ordered tree. – A parent node may have any number of children. – Child nodes are ordered, and may have siblings. • Preorder traversals are usually used for getting information out of the tree.
  • 26. Excellence and Service CHRIST Deemed to be University Validity • A well-formed document has a tree structure and obeys all the XML rules. • A particular application may add more rules in either a DTD (document type definition) or in a schema. • Many specialized DTDs and schemas have been created to describe particular areas. • These range from disseminating news bulletins (RSS) to chemical formulas. • DTDs were developed first, so they are not as comprehensive as schema.
  • 27. Excellence and Service CHRIST Deemed to be University XML Entity References • Chars used for constructing tags • &lt - < • &gt - > • &amp - & • &quot - “” • &apos – ‘
  • 28. Excellence and Service CHRIST Deemed to be University XML Parser • Non validating parser – validates XML not DTD • Validating Parser – Validates both • Eg., expat, SAXI (simple Api for XML), Xerces, MSXML
  • 29. Excellence and Service CHRIST Deemed to be University XML Parser
  • 30. Excellence and Service CHRIST Deemed to be University QUIZ TIME • https://www.w3schools.com/ quiztest/quiztest.asp?qtest= XML
  • 31. Excellence and Service CHRIST Deemed to be University Document Type Definitions(DTD) • A DTD describes the tree structure of a document and something about its data. • Validate the XML • There are two data types, PCDATA and CDATA. – PCDATA is parsed character data. – CDATA is character data, not usually parsed. • A DTD determines how many times a node may appear, and how child nodes are ordered.
  • 32. Excellence and Service CHRIST Deemed to be University DTD for address Example <!ELEMENT address (name, email, phone, birthday)> <!ELEMENT name (first, last)> <!ELEMENT first (#PCDATA)> <!ELEMENT last (#PCDATA)> <!ELEMENT email (#PCDATA)> <!ELEMENT phone (#PCDATA)> <!ELEMENT birthday (year, month, day)> <!ELEMENT year (#PCDATA)> <!ELEMENT month (#PCDATA)> <!ELEMENT day (#PCDATA)>
  • 33. Excellence and Service CHRIST Deemed to be University Declaration of DTD • Internal eg. internaldtd.xml • External eg. Drink.xml drink.dtd
  • 34. Excellence and Service CHRIST Deemed to be University DTD declaration • DTD for single element • DTD for nested elements • Defining Attributes in DTD • Defining entities in DTD • Referencing External entities
  • 35. Excellence and Service CHRIST Deemed to be University DTD for single element • DTD for a single element, which does not contain any text or other element • <?xml version=“1.0” encoding=“UTF-8”?> <!ELEMENT PRODUCTDATA(PRODUCT+) • ? - Applies to 0 or 1 element • * - Applies to 0 or more elements • + - Applies to one or more elements
  • 36. Excellence and Service CHRIST Deemed to be University DTD for nested elements <!ELEMENT PRODUCTDATA(PRODUCT+)> <!ELEMENT PRODUCT (PRODUCTNAME, DESCRIPTION)> <!ELEMENT PRODUCTNAME(#PCDATA)> <!ELEMENT DESCRIPTION(#PCDATA)> <!ELEMENT item (#PCDATA | item)*>
  • 37. Excellence and Service CHRIST Deemed to be University Defining Attributes in DTD • <!ATTLIST element-name attribute-name attribute-type default- value> • <!ATTLIST salary type CDATA “check”> • Attribute type desc (values | value|..) Values sep. by | CDATA Unparsed data ENTITIES ENTITY ID IDREF IDREFS NMTOKEN NMTOKENS NOTATION
  • 38. Excellence and Service CHRIST Deemed to be University Default Values • Value Description value default value for the attribute #REQUIRED Compulsory #IMPLIED Not Compulsory # FIXED value Fixed value for the attribute
  • 39. Excellence and Service CHRIST Deemed to be University Defining entities in DTD • Shortcuts that can be replaced by completed definition <!ENTITY entity-name SYSTEM “URI/URL”> <!ENTITY entity-name “entity definition”> EG. <!ENTITY writer “Ken Thompson”> <!ENTITY copyright “Christ 2019”> <author > &writer;&copyright;</author>
  • 40. Excellence and Service CHRIST Deemed to be University Referencing External entities • SYSTEM / PUBLIC identifier <!DOCTYPE books SYSTEM “books.dtd” [ <!ENTITY writer “Ken Thompson”> <!ENTITY copyright SYSTEM “COPYRIGHT.XML”> ]> <author > &writer;&copyright;</author>
  • 41. Excellence and Service CHRIST Deemed to be University XML Namespaces • URI – uniqueness to the names of elements and attributes of the XML documents. • Combine the different elements/attributes • (same name??) / conflict • NAME PREFIX TO THE ELEMENT • <n:table> • Xmlns: prefix=“URI” Chap. 29
  • 42. Excellence and Service CHRIST Deemed to be University Schemas • Defines the structure of a XML document • Schemas are themselves XML documents. • Validate the structure of a XML file by parser. • Standardized after DTDs and provide more information about the document by XML Schema Document (XSD). • Number of data types including string, decimal, integer, boolean, date, and time. • Divide elements into simple and complex types. • Determine the tree structure and how many children a node may have.
  • 43. Excellence and Service CHRIST Deemed to be University DTD vs SCHEMA DTD Schema • elements, attributes structure of the and entities element with data type • No namespaces • XML syntax not followed • Strong Typing simple and complex data types
  • 44. Excellence and Service CHRIST Deemed to be University Schema definition <xs:element name=“name” type=“type”/> Data types: xs_string xs_date xs_numeric xs_misc Types: Simple - text Complex - child elements and attributes
  • 45. Excellence and Service CHRIST Deemed to be University Schema for First address Example <?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="address"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="email" type="xs:string"/> <xs:element name="phone" type="xs:string"/> <xs:element name="birthday" type="xs:date"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Eg.
  • 46. Excellence and Service CHRIST Deemed to be University Explanation of Example Schema <?xml version="1.0" encoding="ISO-8859-1" ?> • ISO-8859-1, Latin-1, is the same as UTF-8 in the first 128 characters. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> • www.w3.org/2001/XMLSchema contains the schema standards. <xs:element name="address"> <xs:complexType> • This states that address is a complex type element. <xs:sequence> • This states that the following elements form a sequence and must come in the order shown. <xs:element name="name" type="xs:string"/> • This says that the element, name, must be a string. <xs:element name="birthday" type="xs:date"/> • This states that the element, birthday, is a date. Dates are always of the form yyyy-mm-dd.
  • 47. Excellence and Service CHRIST Deemed to be University XSLT Extensible Stylesheet Language Transformations • XSLT is used to transform one xml document into another, often an html document. • The Transform classes are now part of Java 1.4. • A program is used that takes as input one xml document and produces as output another. • If the resulting document is in html, it can be viewed by a web browser. • This is a good way to display xml data.
  • 48. Excellence and Service CHRIST Deemed to be University A Style Sheet to Transform address.xml <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="address"> <html><head><title>Address Book</title></head> <body> <xsl:value-of select="name"/> <br/><xsl:value-of select="email"/> <br/><xsl:value-of select="phone"/> <br/><xsl:value-of select="birthday"/> </body> </html> </xsl:template> </xsl:stylesheet>
  • 49. Excellence and Service CHRIST Deemed to be University The Result of the Transformation Alice Lee alee@aol.com 123-45-6789 1983-7-15
  • 50. Excellence and Service CHRIST Deemed to be University Parsers • There are two principal models for parsers. • SAX – Simple API for XML – Uses a call-back method – Similar to javax listeners • DOM – Document Object Model – Creates a parse tree – Requires a tree traversal
  • 51. Excellence and Service CHRIST Deemed to be University References • Elliotte Rusty Harold, Processing XML with Java, Addison Wesley, 2002. • Elliotte Rusty Harold and Scott Means, XML Programming, O’Reilly & Associates, Inc., 2002. • W3Schools Online Web Tutorials, http://www.w3schools.com.