SlideShare a Scribd company logo
K.Sasidhar
What is XML?What is XML?
 XML stands for EXtensible Markup
Language
 XML is a markup language much like
HTML
 XML was designed to carry data, not to
display data
 XML tags are not predefined. You must
define your own tags
 XML is designed to be self-descriptive
 XML is a W3C Recommendation
K.Sasidhar
The Difference Between XML andThe Difference Between XML and
HTMLHTML
 XML is not a replacement for HTML.
 XML and HTML were designed with
different goals:
 XML was designed to transport and
store data, with focus on what data is
 HTML was designed to display data,
with focus on how data looks
 HTML is about displaying information,
while XML is about carrying information.
 XML was created to structure, store,
and transport information.
 XML language has no predefined tags
K.Sasidhar
Differences continue….Differences continue….
 XML is used to transport data, while
HTML is used to format and display the
data.
 XML is a software- and hardware-
independent tool for carrying information.
 With XML You Invent Your Own Tags
 XML is a W3C Recommendation
K.Sasidhar
Facts of XMLFacts of XML
 XML Separates Data from HTMLXML Separates Data from HTML
 If you need to display dynamic data in yourIf you need to display dynamic data in your
HTML document, it will take a lot of work toHTML document, it will take a lot of work to
edit the HTML each time the data changes.edit the HTML each time the data changes.
 With XML, data can be stored in separateWith XML, data can be stored in separate
XML files. This way you can concentrate onXML files. This way you can concentrate on
using HTML/CSS for display and layout,using HTML/CSS for display and layout,
and be sure that changes in the underlyingand be sure that changes in the underlying
data will not require any changes to thedata will not require any changes to the
HTML.HTML.
 With a few lines of JavaScript code, youWith a few lines of JavaScript code, you
can read an external XML file and updatecan read an external XML file and update
the data content of your web page.the data content of your web page.
K.Sasidhar
Facts of XMLFacts of XML
 XML Simplifies Data Sharing
 XML data is stored in plain text format.
This provides a software- and hardware-
independent way of storing data.
 This makes it much easier to create
data that can be shared by different
applications.
 XML Simplifies Data Transport
 One of the most time-consuming
challenges for developers is to
exchange data between incompatible
systems over the Internet.
K.Sasidhar
FACTS OF XMLFACTS OF XML
 XML Simplifies Platform ChangesXML Simplifies Platform Changes
 XML Makes Your Data MoreXML Makes Your Data More
AvailableAvailable
 XML is a meta mark up languageXML is a meta mark up language
that specifies rules for creatingthat specifies rules for creating
markup languagesmarkup languages
K.Sasidhar
XML DOCUMENT CONTENTXML DOCUMENT CONTENT
 XML Document composed of
 1. Declarations (dtd reference)
 2. Elements
 3. Comments
 4. Entities (Pre-defined, Custom
– defined, character)
K.Sasidhar
Root StructureRoot Structure
K.Sasidhar
XML SYNTAXXML SYNTAX
 Syntax is two levels.Syntax is two levels.
 Low level syntax that imposeLow level syntax that impose
rules on all xml documents.rules on all xml documents.
 Other level is either documentOther level is either document
type definition (DTD) or XMLtype definition (DTD) or XML
schemas.schemas.
K.Sasidhar
XML Syntax Continues….XML Syntax Continues….
 DTDs and schemas specify theDTDs and schemas specify the
set of tags and attributes thatset of tags and attributes that
can appear in a particularcan appear in a particular
document or collection ofdocument or collection of
documents.documents.
 Also specify the order andAlso specify the order and
arrangement in which they canarrangement in which they can
appear.appear.
K.Sasidhar
XML StatementsXML Statements
 ElementsElements
 Markup declarations areMarkup declarations are
instructions to the xml parser,instructions to the xml parser,
and processing instructions.and processing instructions.
K.Sasidhar
XML Program structureXML Program structure
 XML declarationXML declaration
 -- identifies the document as XML and provides the-- identifies the document as XML and provides the
version number of XML.version number of XML.
 CommentsComments
 Same as HTMLSame as HTML
 XML namesXML names
 Names are used to name elements and attributes.Names are used to name elements and attributes.
 Names are case sensitiveNames are case sensitive
K.Sasidhar
ElementsElements
 Root elementRoot element
 Xml document defines a single root element,Xml document defines a single root element,
opening tag and must appear on the first line of theopening tag and must appear on the first line of the
code.code.
 All other elements must be nested inside the rootAll other elements must be nested inside the root
element.element.
K.Sasidhar
EX. PROGRAMEX. PROGRAM
 <?xml version = “1.0” encoding= “utf-8”?><?xml version = “1.0” encoding= “utf-8”?>
 <ad><ad>
 <year> 2012</year><year> 2012</year>
 <make> Maruthi </make><make> Maruthi </make>
 <model> Alto Lxi </model><model> Alto Lxi </model>
 <color> blue</color><color> blue</color>
 <location><location>
 <city> hyderabad </city><city> hyderabad </city>
 <state> AP </state><state> AP </state>
 </location></location>
 </ad></ad>
K.Sasidhar
Document Type Definitions
 DTD is a set of structural rules called
declarations.
 DTD Specify the position of a set of
elements.
 DTD Provides entity definitions also.
 DTDs are used when the same tag set
definition is used by a collection of
documents, perhaps by a collection of
users, and the documents must have a
consistent and uniform structure.
K.Sasidhar
DTD
 DTD that embedded with XML is called
internal DTD.
 DTD stored in a separate file is called
external DTD.
 External DTD allows use with more than
one XML document, and are preferable.
 DTD defines the document structure with
a list of legal elements and attributes.
K.Sasidhar
Internal DTD Example
 <?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>clerk</to>
<from>HOD</from>
<heading>Issue Hall Tickets</heading>
<body>Issue the hall tickets for those who had
required attendance</body>
</note>
K.Sasidhar
DTD ex: explanation
 The DTD above is interpreted like this:
 !DOCTYPE note defines that the root element of
this document is note
 !ELEMENT note defines that the note element
contains four elements: "to,from,heading,body"
 !ELEMENT to defines the to element to be of
type "#PCDATA"
 !ELEMENT from defines the from element to be
of type "#PCDATA"
 !ELEMENT heading defines the heading element
to be of type "#PCDATA"
 !ELEMENT body defines the body element to be
of type "#PCDATA"
K.Sasidhar
External DTD declaration ex:
 <!ELEMENT note
(to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading
(#PCDATA)>
<!ELEMENT body (#PCDATA)>
K.Sasidhar
DTD continue….
 <?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>clerk</to>
<from>HOD</from>
<heading>Issue Hall Tickets </heading>
<body> Issue the hall tickets for those
who had required attendance </body>
</note>
K.Sasidhar
XML Building Blocks
 Tags
 Elements
 Attributes
 Entities
 PCDATA (Parsable Character Data)
 CDATA
K.Sasidhar
Element descriptions
 Suffixes:
? optional
+ one or more
* zero or more
 Separators
, both, in order
| or
 Grouping
( ) grouping
K.Sasidhar
Empty elements
 <!ELEMENT element-name
EMPTY>
Example:
<!ELEMENT br EMPTY>
XML example:
<br />
K.Sasidhar
Elements with Parsed Character
Data
 <!ELEMENT from (#PCDATA)>
K.Sasidhar
Elements with any Contents
 Elements declared with the category
keyword ANY, can contain any
combination of parsable data
 <!ELEMENT element-name ANY>
Example:
<!ELEMENT note ANY>
K.Sasidhar
Elements with Children
(sequences)
 <!ELEMENT element-name (child1)>
or
<!ELEMENT element-name
(child1,child2,...)>
Example:
<!ELEMENT note
(to,from,heading,body)>
K.Sasidhar
DTD - Attributes
 In a DTD, attributes are declared with an
ATTLIST declaration.
 Syntax:
 <!ATTLIST element-name attribute-name
attribute-type default-value>
 DTD example:
<!ATTLIST payment type CDATA "check">
XML example:
<payment type="check" />
K.Sasidhar
Attribute types
 The attribute-type can be one of the following:
CDATA The value is character
data
(en1|en2|..) Value from enum list
ID Value is unique id
IDREF Value is id of another
element
IDREFS Value is list of other ids
NMTOKEN Valid xml name
ENTITY Value is an entity
ENTITITES List of entities
notation Value is name of notation
Xml: Value is predefined xml
value
K.Sasidhar
Elements vs. Attributes
 Data can be stored in child elements
or in attributes.
 <person gender ="male">
<firstname>sravan</firstname>
<lastname>kota</lastname>
</person>
 gender is attribute in this
example.
K.Sasidhar
Elements vs. Attributes continue..
 <person>
<gender>male</gender>
<firstname>sravan</firstname>
<lastname>kota</lastname>
</person>
 gender is child element in this
example.
 No rules are there when to use
attributes or elements.
 It depends on programmer
 If the programmer feels information is
useful better to use elements.
K.Sasidhar
Problems with attributes
 attributes cannot contain multiple
values (child elements can)
 attributes are not easily expandable
(for future changes)
 attributes cannot describe structures
(child elements can)
 attributes are more difficult to
manipulate by program code
 attribute values are not easy to test
against a DTD
K.Sasidhar
ENTITIES
 Entities are variables used to define shortcuts
to standard text or special characters.
 Entities can be declared internal or external
 Internal entity syntax:
 <!ENTITY entity-name "entity-value">
 DTD Example:
<!ENTITY writer "Donald Duck.">
<!ENTITY copyright "Copyright of Disney.">
XML example:
<author>&writer; &copyright;</author>
 Note: entity has 3 parts. &, name and ;
K.Sasidhar
External Entity Declaration
 Syntax
 <!ENTITY entity-name SYSTEM "URL">
 DTD Example:
<!ENTITY college SYSTEM
"http://www.sreenidhi.com/entities.dtd">
<!ENTITY copyright SYSTEM
"http://www.sreenidhi.com/entities.dtd">
XML example:
<author>&writer;&copyright;</author>
Note: entity has 3 parts. &, name and ;
K.Sasidhar
Important Keywords in DTD
 #REQUIRED
 #IMPLIED
 #FIXED
 #PCDATA
K.Sasidhar
DTDs DISADVANTAGES
 DTDs are written in a syntax unrelated to
XML.
 Cannot be analyzed with an xml
processor
 Confusion to deal with two different
syntactic formats ( one to define
document and two to define its structure).
 DTD data types are not numeric.
 With DTDs the content of an element
specified as text even though it could be
an integer, floating-point number or a
range of numbers.
K.Sasidhar
XML Schema
 XML Schema describes the structure of an
XML document.
 The XML Schema language is also
referred to as XML Schema Definition
(XSD).
K.Sasidhar
XML Schema Vs DTD
Xml schema DTD
Created by using xml
syntax.
Xml style sheets (XSL) are
used with xml schemas.
Not allowed with xsl
Supports Namespaces No namespaces
Supports more data types
including number and
derived data types
Supports only character
data types
Easy to create and edit
complex content
Difficult to reusable
Xml schema can be
parsable by xml parsers
Cannot parsable
K.Sasidhar
Use of XML Schema in web design
 Defines root and child elements that
can appear in a document
 Defines attributes that can appear in a
document
 Defines the order and number of child
elements
 Defines whether an element is empty
or can include text
 Defines data types for elements and
attributes
 Defines default and fixed values for
elements and attributes
K.Sasidhar
XML Schema importance …..
 XML Schemas are extensible to
future additions
 XML Schemas are richer and
more powerful than DTDs
 XML Schemas support data
types and namespaces
K.Sasidhar
Importance continues…
 XML Schema is an xml
document so it can be parsed
with an xml parser.
 Provides more control over data
types than DTDs.
 XML schemas are namespace
centric.
K.Sasidhar
Fundamentals
 Schemas are like class and
object in oop language.
 Schema is similar to class
definition
 Xml document that conforms to
the structure defined in the
schema is similar to an object of
the schema’s class.
K.Sasidhar
Purposes of schemas
 Have 2 primary purposes.
 First, a schema specifies the structure
of its instance XML documents,
including which elements and
attributes may appear in the instance
document, as well as where and how
often they may appear.
 Second, schema specifies the data
type of every element and attribute of
its instance XML documents.
K.Sasidhar
Defining a schema
 Every schema has schema as its root
element.
 Schema element specifies the namespace
for the schema of schemas from which the
schema’s elements and attributes will be
drawn.
 Xmlns:xsd = “http://www.w3.org/2001/XMLSchema”
K.Sasidhar
Ex Program
<?xml version="1.0"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/X
MLSchema"
targetNamespace="http://www.sreeni
dhi.com"
xmlns="http://www.sreenidhi.com"
elementFormDefault="qualified">
...
...
</xs:schema>
K.Sasidhar
explanation
 xmlns:xs="http://www.w3.org/2001/X
MLSchema"
 indicates that the elements and data types
used in the schema come from the
"http://www.w3.org/2001/XMLSchema"
namespace. It also specifies that the
elements and data types that come from the
"http://www.w3.org/2001/XMLSchema"
namespace should be prefixed with xs:
 targetNamespace="http://www.sreenidhi.co
m"
 indicates that the elements defined by this
schema (note, to, from, heading, body.)
come from the "http://www.sreenidhi.com"
namespace.
K.Sasidhar
explanation
 xmlns=http://www.sreenidhi.com
 indicates that the default
namespace is
"http://www.sreenidhi.com".
 elementFormDefault="qualified"
 indicates that any elements used
by the XML instance document
which were declared in this
schema must be namespace
qualified.
K.Sasidhar
XML Schema reference
 <?xml version="1.0"?>
<note xmlns="http://www.sreenidhi.com"
xmlns:xsi="http://www.w3.org/2001/XMLSc
hema-instance"
xsi:schemaLocation="http://www.sreenidhi.
com note.xsd">
<to>clerk</to>
<from>HOD</from>
<heading>Issue Hall Tickets</heading>
<body> Issue the hall tickets for those who
had required attendance </body>
</note>
K.Sasidhar
Data Types
 Binary: Supports hexa code
 Logic data types: Boolean
 Number data types: Float, double, decimal,
long
 Date and time data types: Time
(hh:mm:ss), duration, date, date time etc..
 Text Data types: URL, string
 XML Data types: Qualified names (qname)
K.Sasidhar
Facets
 EX: Facets of integer primitive data
type has eight possible facets:
 totalDigits, maxInclusive,
maxExclusive, minInclusive,
minExclusive, pattern, enumeration
and whitespace.
 This list can be found at
 www.w3.org/TR/xmlschema-2/#built-
in-datatypes.
K.Sasidhar
Simple types
 <xsd: element name=“engine”
type = “xsd:string” />
 An instance of schema in which
the engine element is defined
could have the following
element
 <engine> inline six cylinder fuel
injected </engine>
K.Sasidhar
Ex:
 <xsd: simpletype name=
“firstname”>
 <xsd: restriction base =
“xsd:string”>
 <xsd:maxLength value = “10”/>
 </xsd:restriction>
 </xsd:simpletype>
K.Sasidhar
Complex types
 <xsd: complexType name = “sports_car”>
 <xsd:sequence>
 <xsd: element name = “make”
type=“xsd:string” />
 <xsd: element name = “model”
type=“xsd:string” />
 <xsd: element name = “engine”
type=“xsd:string” />
 <xsd: element name = “year”
type=“xsd:decimal” />
 </xsd:sequence>
 </xsd: complexType>

More Related Content

What's hot (20)

PPTX
Xml dtd
HeenaRajput1
 
PPT
XML Schema
yht4ever
 
PPTX
XML's validation - XML Schema
videde_group
 
PPTX
XML Introduction
Bikash chhetri
 
PPT
Introduction to XML
yht4ever
 
PPTX
Xml dtd
sana mateen
 
PPTX
XML, DTD & XSD Overview
Pradeep Rapolu
 
PDF
Introduction to DTD
torp42
 
PPTX
DTD
Kamal Acharya
 
PPT
2 dtd - validating xml documents
gauravashq
 
PPTX
Xml basics
Kumar
 
PPT
4 xml namespaces and xml schema
gauravashq
 
DOCX
Introduction to xml schema
Abhishek Kesharwani
 
PPT
10. XML in DBMS
koolkampus
 
PDF
Xml schema
Dr.Saranya K.G
 
PPT
Dtd
vikram singh
 
PPT
Xsd examples
Bình Trọng Án
 
Xml dtd
HeenaRajput1
 
XML Schema
yht4ever
 
XML's validation - XML Schema
videde_group
 
XML Introduction
Bikash chhetri
 
Introduction to XML
yht4ever
 
Xml dtd
sana mateen
 
XML, DTD & XSD Overview
Pradeep Rapolu
 
Introduction to DTD
torp42
 
2 dtd - validating xml documents
gauravashq
 
Xml basics
Kumar
 
4 xml namespaces and xml schema
gauravashq
 
Introduction to xml schema
Abhishek Kesharwani
 
10. XML in DBMS
koolkampus
 
Xml schema
Dr.Saranya K.G
 
Xsd examples
Bình Trọng Án
 

Similar to Xml sasidhar (20)

PPTX
Internet_Technology_UNIT V- Introduction to XML.pptx
shilpar780389
 
PPTX
Web Technology Part 4
Thapar Institute
 
PPTX
distributed system concerned lab sessions
milkesa13
 
PPTX
web design technology- mark up languages
ssuser2efca7
 
PPTX
Xml 1
pavishkumarsingh
 
PDF
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
Dr.Florence Dayana
 
PPT
Introduction to XML.ppt
Varsha Uchagaonkar
 
PPT
Introduction to XML.ppt
Varsha Uchagaonkar
 
PPT
Intro to xml
Tarun Jain
 
PPT
web program-Extended MARKUP Language XML.ppt
mcjaya2024
 
PPT
Ch2 neworder
davidlahr32
 
PPTX
Basics of Xml
Jerry Kurian
 
PPT
XML-Unit 1.ppt
ssuseree7dcd
 
PPTX
Unit 5 xml (1)
manochitra10
 
PPT
cis110-xml-xhtml engineering computer science
ash0014as
 
PDF
WT UNIT-2 XML.pdf
Ranjeet Reddy
 
PDF
Web Technologies Unit 2 Print.pdf
AnonymousXhmybK
 
PDF
XML
Prabu U
 
PPT
1 xml fundamentals
Dr.Saranya K.G
 
DOCX
Oracle soa xml faq
xavier john
 
Internet_Technology_UNIT V- Introduction to XML.pptx
shilpar780389
 
Web Technology Part 4
Thapar Institute
 
distributed system concerned lab sessions
milkesa13
 
web design technology- mark up languages
ssuser2efca7
 
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
Dr.Florence Dayana
 
Introduction to XML.ppt
Varsha Uchagaonkar
 
Introduction to XML.ppt
Varsha Uchagaonkar
 
Intro to xml
Tarun Jain
 
web program-Extended MARKUP Language XML.ppt
mcjaya2024
 
Ch2 neworder
davidlahr32
 
Basics of Xml
Jerry Kurian
 
XML-Unit 1.ppt
ssuseree7dcd
 
Unit 5 xml (1)
manochitra10
 
cis110-xml-xhtml engineering computer science
ash0014as
 
WT UNIT-2 XML.pdf
Ranjeet Reddy
 
Web Technologies Unit 2 Print.pdf
AnonymousXhmybK
 
XML
Prabu U
 
1 xml fundamentals
Dr.Saranya K.G
 
Oracle soa xml faq
xavier john
 
Ad

More from Sasidhar Kothuru (20)

PPT
Spsl vi unit final
Sasidhar Kothuru
 
PPT
Spsl iv unit final
Sasidhar Kothuru
 
PPT
Spsl v unit - final
Sasidhar Kothuru
 
PPT
Spsl iv unit final
Sasidhar Kothuru
 
PPT
Spsl v unit - final
Sasidhar Kothuru
 
PPT
Spsl by sasidhar 3 unit
Sasidhar Kothuru
 
PPT
Spsl unit1
Sasidhar Kothuru
 
PPT
Spsl II unit
Sasidhar Kothuru
 
PPT
Jdbc sasidhar
Sasidhar Kothuru
 
PPT
Servlets
Sasidhar Kothuru
 
PPT
Servers names
Sasidhar Kothuru
 
PPT
Servers names
Sasidhar Kothuru
 
PPT
Web Technologies -- Servlets 4 unit slides
Sasidhar Kothuru
 
DOC
Xml quiz 3 unit
Sasidhar Kothuru
 
DOC
Web technologies quiz questions - unit1,2
Sasidhar Kothuru
 
DOC
Web technologies 4th unit quiz
Sasidhar Kothuru
 
DOC
Xml quiz 3 unit
Sasidhar Kothuru
 
DOC
Web technologies quiz questions - unit1,2
Sasidhar Kothuru
 
PPT
Jsp sasidhar
Sasidhar Kothuru
 
PPT
Java script -23jan2015
Sasidhar Kothuru
 
Spsl vi unit final
Sasidhar Kothuru
 
Spsl iv unit final
Sasidhar Kothuru
 
Spsl v unit - final
Sasidhar Kothuru
 
Spsl iv unit final
Sasidhar Kothuru
 
Spsl v unit - final
Sasidhar Kothuru
 
Spsl by sasidhar 3 unit
Sasidhar Kothuru
 
Spsl unit1
Sasidhar Kothuru
 
Spsl II unit
Sasidhar Kothuru
 
Jdbc sasidhar
Sasidhar Kothuru
 
Servers names
Sasidhar Kothuru
 
Servers names
Sasidhar Kothuru
 
Web Technologies -- Servlets 4 unit slides
Sasidhar Kothuru
 
Xml quiz 3 unit
Sasidhar Kothuru
 
Web technologies quiz questions - unit1,2
Sasidhar Kothuru
 
Web technologies 4th unit quiz
Sasidhar Kothuru
 
Xml quiz 3 unit
Sasidhar Kothuru
 
Web technologies quiz questions - unit1,2
Sasidhar Kothuru
 
Jsp sasidhar
Sasidhar Kothuru
 
Java script -23jan2015
Sasidhar Kothuru
 
Ad

Recently uploaded (20)

PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 

Xml sasidhar

  • 1. K.Sasidhar What is XML?What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data  XML tags are not predefined. You must define your own tags  XML is designed to be self-descriptive  XML is a W3C Recommendation
  • 2. K.Sasidhar The Difference Between XML andThe Difference Between XML and HTMLHTML  XML is not a replacement for HTML.  XML and HTML were designed with different goals:  XML was designed to transport and store data, with focus on what data is  HTML was designed to display data, with focus on how data looks  HTML is about displaying information, while XML is about carrying information.  XML was created to structure, store, and transport information.  XML language has no predefined tags
  • 3. K.Sasidhar Differences continue….Differences continue….  XML is used to transport data, while HTML is used to format and display the data.  XML is a software- and hardware- independent tool for carrying information.  With XML You Invent Your Own Tags  XML is a W3C Recommendation
  • 4. K.Sasidhar Facts of XMLFacts of XML  XML Separates Data from HTMLXML Separates Data from HTML  If you need to display dynamic data in yourIf you need to display dynamic data in your HTML document, it will take a lot of work toHTML document, it will take a lot of work to edit the HTML each time the data changes.edit the HTML each time the data changes.  With XML, data can be stored in separateWith XML, data can be stored in separate XML files. This way you can concentrate onXML files. This way you can concentrate on using HTML/CSS for display and layout,using HTML/CSS for display and layout, and be sure that changes in the underlyingand be sure that changes in the underlying data will not require any changes to thedata will not require any changes to the HTML.HTML.  With a few lines of JavaScript code, youWith a few lines of JavaScript code, you can read an external XML file and updatecan read an external XML file and update the data content of your web page.the data content of your web page.
  • 5. K.Sasidhar Facts of XMLFacts of XML  XML Simplifies Data Sharing  XML data is stored in plain text format. This provides a software- and hardware- independent way of storing data.  This makes it much easier to create data that can be shared by different applications.  XML Simplifies Data Transport  One of the most time-consuming challenges for developers is to exchange data between incompatible systems over the Internet.
  • 6. K.Sasidhar FACTS OF XMLFACTS OF XML  XML Simplifies Platform ChangesXML Simplifies Platform Changes  XML Makes Your Data MoreXML Makes Your Data More AvailableAvailable  XML is a meta mark up languageXML is a meta mark up language that specifies rules for creatingthat specifies rules for creating markup languagesmarkup languages
  • 7. K.Sasidhar XML DOCUMENT CONTENTXML DOCUMENT CONTENT  XML Document composed of  1. Declarations (dtd reference)  2. Elements  3. Comments  4. Entities (Pre-defined, Custom – defined, character)
  • 9. K.Sasidhar XML SYNTAXXML SYNTAX  Syntax is two levels.Syntax is two levels.  Low level syntax that imposeLow level syntax that impose rules on all xml documents.rules on all xml documents.  Other level is either documentOther level is either document type definition (DTD) or XMLtype definition (DTD) or XML schemas.schemas.
  • 10. K.Sasidhar XML Syntax Continues….XML Syntax Continues….  DTDs and schemas specify theDTDs and schemas specify the set of tags and attributes thatset of tags and attributes that can appear in a particularcan appear in a particular document or collection ofdocument or collection of documents.documents.  Also specify the order andAlso specify the order and arrangement in which they canarrangement in which they can appear.appear.
  • 11. K.Sasidhar XML StatementsXML Statements  ElementsElements  Markup declarations areMarkup declarations are instructions to the xml parser,instructions to the xml parser, and processing instructions.and processing instructions.
  • 12. K.Sasidhar XML Program structureXML Program structure  XML declarationXML declaration  -- identifies the document as XML and provides the-- identifies the document as XML and provides the version number of XML.version number of XML.  CommentsComments  Same as HTMLSame as HTML  XML namesXML names  Names are used to name elements and attributes.Names are used to name elements and attributes.  Names are case sensitiveNames are case sensitive
  • 13. K.Sasidhar ElementsElements  Root elementRoot element  Xml document defines a single root element,Xml document defines a single root element, opening tag and must appear on the first line of theopening tag and must appear on the first line of the code.code.  All other elements must be nested inside the rootAll other elements must be nested inside the root element.element.
  • 14. K.Sasidhar EX. PROGRAMEX. PROGRAM  <?xml version = “1.0” encoding= “utf-8”?><?xml version = “1.0” encoding= “utf-8”?>  <ad><ad>  <year> 2012</year><year> 2012</year>  <make> Maruthi </make><make> Maruthi </make>  <model> Alto Lxi </model><model> Alto Lxi </model>  <color> blue</color><color> blue</color>  <location><location>  <city> hyderabad </city><city> hyderabad </city>  <state> AP </state><state> AP </state>  </location></location>  </ad></ad>
  • 15. K.Sasidhar Document Type Definitions  DTD is a set of structural rules called declarations.  DTD Specify the position of a set of elements.  DTD Provides entity definitions also.  DTDs are used when the same tag set definition is used by a collection of documents, perhaps by a collection of users, and the documents must have a consistent and uniform structure.
  • 16. K.Sasidhar DTD  DTD that embedded with XML is called internal DTD.  DTD stored in a separate file is called external DTD.  External DTD allows use with more than one XML document, and are preferable.  DTD defines the document structure with a list of legal elements and attributes.
  • 17. K.Sasidhar Internal DTD Example  <?xml version="1.0"?> <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]> <note> <to>clerk</to> <from>HOD</from> <heading>Issue Hall Tickets</heading> <body>Issue the hall tickets for those who had required attendance</body> </note>
  • 18. K.Sasidhar DTD ex: explanation  The DTD above is interpreted like this:  !DOCTYPE note defines that the root element of this document is note  !ELEMENT note defines that the note element contains four elements: "to,from,heading,body"  !ELEMENT to defines the to element to be of type "#PCDATA"  !ELEMENT from defines the from element to be of type "#PCDATA"  !ELEMENT heading defines the heading element to be of type "#PCDATA"  !ELEMENT body defines the body element to be of type "#PCDATA"
  • 19. K.Sasidhar External DTD declaration ex:  <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)>
  • 20. K.Sasidhar DTD continue….  <?xml version="1.0"?> <!DOCTYPE note SYSTEM "note.dtd"> <note> <to>clerk</to> <from>HOD</from> <heading>Issue Hall Tickets </heading> <body> Issue the hall tickets for those who had required attendance </body> </note>
  • 21. K.Sasidhar XML Building Blocks  Tags  Elements  Attributes  Entities  PCDATA (Parsable Character Data)  CDATA
  • 22. K.Sasidhar Element descriptions  Suffixes: ? optional + one or more * zero or more  Separators , both, in order | or  Grouping ( ) grouping
  • 23. K.Sasidhar Empty elements  <!ELEMENT element-name EMPTY> Example: <!ELEMENT br EMPTY> XML example: <br />
  • 24. K.Sasidhar Elements with Parsed Character Data  <!ELEMENT from (#PCDATA)>
  • 25. K.Sasidhar Elements with any Contents  Elements declared with the category keyword ANY, can contain any combination of parsable data  <!ELEMENT element-name ANY> Example: <!ELEMENT note ANY>
  • 26. K.Sasidhar Elements with Children (sequences)  <!ELEMENT element-name (child1)> or <!ELEMENT element-name (child1,child2,...)> Example: <!ELEMENT note (to,from,heading,body)>
  • 27. K.Sasidhar DTD - Attributes  In a DTD, attributes are declared with an ATTLIST declaration.  Syntax:  <!ATTLIST element-name attribute-name attribute-type default-value>  DTD example: <!ATTLIST payment type CDATA "check"> XML example: <payment type="check" />
  • 28. K.Sasidhar Attribute types  The attribute-type can be one of the following: CDATA The value is character data (en1|en2|..) Value from enum list ID Value is unique id IDREF Value is id of another element IDREFS Value is list of other ids NMTOKEN Valid xml name ENTITY Value is an entity ENTITITES List of entities notation Value is name of notation Xml: Value is predefined xml value
  • 29. K.Sasidhar Elements vs. Attributes  Data can be stored in child elements or in attributes.  <person gender ="male"> <firstname>sravan</firstname> <lastname>kota</lastname> </person>  gender is attribute in this example.
  • 30. K.Sasidhar Elements vs. Attributes continue..  <person> <gender>male</gender> <firstname>sravan</firstname> <lastname>kota</lastname> </person>  gender is child element in this example.  No rules are there when to use attributes or elements.  It depends on programmer  If the programmer feels information is useful better to use elements.
  • 31. K.Sasidhar Problems with attributes  attributes cannot contain multiple values (child elements can)  attributes are not easily expandable (for future changes)  attributes cannot describe structures (child elements can)  attributes are more difficult to manipulate by program code  attribute values are not easy to test against a DTD
  • 32. K.Sasidhar ENTITIES  Entities are variables used to define shortcuts to standard text or special characters.  Entities can be declared internal or external  Internal entity syntax:  <!ENTITY entity-name "entity-value">  DTD Example: <!ENTITY writer "Donald Duck."> <!ENTITY copyright "Copyright of Disney."> XML example: <author>&writer; &copyright;</author>  Note: entity has 3 parts. &, name and ;
  • 33. K.Sasidhar External Entity Declaration  Syntax  <!ENTITY entity-name SYSTEM "URL">  DTD Example: <!ENTITY college SYSTEM "http://www.sreenidhi.com/entities.dtd"> <!ENTITY copyright SYSTEM "http://www.sreenidhi.com/entities.dtd"> XML example: <author>&writer;&copyright;</author> Note: entity has 3 parts. &, name and ;
  • 34. K.Sasidhar Important Keywords in DTD  #REQUIRED  #IMPLIED  #FIXED  #PCDATA
  • 35. K.Sasidhar DTDs DISADVANTAGES  DTDs are written in a syntax unrelated to XML.  Cannot be analyzed with an xml processor  Confusion to deal with two different syntactic formats ( one to define document and two to define its structure).  DTD data types are not numeric.  With DTDs the content of an element specified as text even though it could be an integer, floating-point number or a range of numbers.
  • 36. K.Sasidhar XML Schema  XML Schema describes the structure of an XML document.  The XML Schema language is also referred to as XML Schema Definition (XSD).
  • 37. K.Sasidhar XML Schema Vs DTD Xml schema DTD Created by using xml syntax. Xml style sheets (XSL) are used with xml schemas. Not allowed with xsl Supports Namespaces No namespaces Supports more data types including number and derived data types Supports only character data types Easy to create and edit complex content Difficult to reusable Xml schema can be parsable by xml parsers Cannot parsable
  • 38. K.Sasidhar Use of XML Schema in web design  Defines root and child elements that can appear in a document  Defines attributes that can appear in a document  Defines the order and number of child elements  Defines whether an element is empty or can include text  Defines data types for elements and attributes  Defines default and fixed values for elements and attributes
  • 39. K.Sasidhar XML Schema importance …..  XML Schemas are extensible to future additions  XML Schemas are richer and more powerful than DTDs  XML Schemas support data types and namespaces
  • 40. K.Sasidhar Importance continues…  XML Schema is an xml document so it can be parsed with an xml parser.  Provides more control over data types than DTDs.  XML schemas are namespace centric.
  • 41. K.Sasidhar Fundamentals  Schemas are like class and object in oop language.  Schema is similar to class definition  Xml document that conforms to the structure defined in the schema is similar to an object of the schema’s class.
  • 42. K.Sasidhar Purposes of schemas  Have 2 primary purposes.  First, a schema specifies the structure of its instance XML documents, including which elements and attributes may appear in the instance document, as well as where and how often they may appear.  Second, schema specifies the data type of every element and attribute of its instance XML documents.
  • 43. K.Sasidhar Defining a schema  Every schema has schema as its root element.  Schema element specifies the namespace for the schema of schemas from which the schema’s elements and attributes will be drawn.  Xmlns:xsd = “http://www.w3.org/2001/XMLSchema”
  • 45. K.Sasidhar explanation  xmlns:xs="http://www.w3.org/2001/X MLSchema"  indicates that the elements and data types used in the schema come from the "http://www.w3.org/2001/XMLSchema" namespace. It also specifies that the elements and data types that come from the "http://www.w3.org/2001/XMLSchema" namespace should be prefixed with xs:  targetNamespace="http://www.sreenidhi.co m"  indicates that the elements defined by this schema (note, to, from, heading, body.) come from the "http://www.sreenidhi.com" namespace.
  • 46. K.Sasidhar explanation  xmlns=http://www.sreenidhi.com  indicates that the default namespace is "http://www.sreenidhi.com".  elementFormDefault="qualified"  indicates that any elements used by the XML instance document which were declared in this schema must be namespace qualified.
  • 47. K.Sasidhar XML Schema reference  <?xml version="1.0"?> <note xmlns="http://www.sreenidhi.com" xmlns:xsi="http://www.w3.org/2001/XMLSc hema-instance" xsi:schemaLocation="http://www.sreenidhi. com note.xsd"> <to>clerk</to> <from>HOD</from> <heading>Issue Hall Tickets</heading> <body> Issue the hall tickets for those who had required attendance </body> </note>
  • 48. K.Sasidhar Data Types  Binary: Supports hexa code  Logic data types: Boolean  Number data types: Float, double, decimal, long  Date and time data types: Time (hh:mm:ss), duration, date, date time etc..  Text Data types: URL, string  XML Data types: Qualified names (qname)
  • 49. K.Sasidhar Facets  EX: Facets of integer primitive data type has eight possible facets:  totalDigits, maxInclusive, maxExclusive, minInclusive, minExclusive, pattern, enumeration and whitespace.  This list can be found at  www.w3.org/TR/xmlschema-2/#built- in-datatypes.
  • 50. K.Sasidhar Simple types  <xsd: element name=“engine” type = “xsd:string” />  An instance of schema in which the engine element is defined could have the following element  <engine> inline six cylinder fuel injected </engine>
  • 51. K.Sasidhar Ex:  <xsd: simpletype name= “firstname”>  <xsd: restriction base = “xsd:string”>  <xsd:maxLength value = “10”/>  </xsd:restriction>  </xsd:simpletype>
  • 52. K.Sasidhar Complex types  <xsd: complexType name = “sports_car”>  <xsd:sequence>  <xsd: element name = “make” type=“xsd:string” />  <xsd: element name = “model” type=“xsd:string” />  <xsd: element name = “engine” type=“xsd:string” />  <xsd: element name = “year” type=“xsd:decimal” />  </xsd:sequence>  </xsd: complexType>