SlideShare a Scribd company logo
1 of 69
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
Lecture #2
XML Introduction
Dr.Adil Alpkocak
Dokuz Eylul University
Dept of Computer Engineering
CME2002
Data Organization and
Management
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Today
• Field and record organization
• XML introduction
2
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Files
A file can be seen as
1. A stream of bytes (no structure), or
2. A collection of records with fields
3
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
#1. File as stream bytes
• File is viewed as a sequence of bytes:
• Data semantics is lost: there is no way to
get it apart again.
4
87359CarrollAlice in wonderland38180FolkFile Structures ...
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
#2: File as a Collection of Records
Definitions
File: Collection of records.
Record: a collection of related fields.
Field: the smallest logically meaningful unit of
information in a file.
Key: a subset of the fields in a record used to
identify (uniquely) the record.
e.g. In the example file of books:
– Each line corresponds to a record.
– Fields in each record: ISBN, Author, Title
5
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Different Notation
column row Table
Field Record File
Attribute Tuple Relation
Terms in the same column are synonyms, and can be used interchangeably.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Record Keys
• Primary key: a key that uniquely identifies a
record.
• Secondary key: other keys that may be used for
search
– Author name
– Book title
– Author name + book title
• Note that in general not every field is a key (keys
correspond to fields, or a combination of fields,
that may be used in a search).
7
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Record Structures
1. Fixed-length records.
2. Fixed number of fields.
3. Begin each record with a length
indicator.
4. Use an index to keep track of
addresses.
5. Place a delimiter at the end of the
record.
8
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
1.Fixed-length records
Two ways of making fixed-length records:
1. Fixed-length records with fixed-length
fields.
2. Fixed-length records with variable-
length fields.
9
87359 Carroll Alice in wonderland
03818 Folk File Structures
87359|Carroll|Alice in wonderland| unused
38180|Folk|File Structures| unused
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Fixed-Length Records
• e.g.
struct PERSON {
char last[11];
char first[11];
char address[16];
char city[16];
char state[3];
char zip[10];
} person;
Will produce a fixed size record of size 67
bytes.
10
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Fixed-Length Records
• The fixed length record structure,
however, does NOT imply, the fixed -
length field structure.
• Fixed-length records are frequently
used as “containers” to hold variable
numbers of variable-length fields.
• Fixed-length record structures are
among the most commonly used
methods for organizing files.
11
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Variable-length records
2. Fixed number of fields:
3. Record beginning with length indicator:
4. Use an index file to keep track of record
addresses:
– The index file keeps the byte offset for each record; this
allows us to search the index (which have fixed length
records) in order to discover the beginning of the record.
5. Placing a delimiter: e.g. end-of-line char
12
87359|Carroll|Alice in wonderland|38180|Folk|File Structures| ...
3387359|Carroll|Alice in wonderland|2638180|Folk|File Structures| ..
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Field Structures
1. Fixed-length fields
87359Carroll Alice in wonderland
38180Folk File Structures
2. Begin each field with a length indicator
058735907Carroll19Alice in wonderland
053818004Folk15File Structures
3. Place a delimiter at the end of each
field
87359|Carroll|Alice in wonderland|
38180|Folk|File Structures|
4. Store field as keyword = value
ISBN=87359|AU=Carroll|TI=Alice in wonderland|
ISBN=38180|AU=Folk|TI=File Structures
13
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Field Structures:
1. Fixing the Length of Fields
This method relies on creating fields
of predictable fixed size.
struct PERSON {
char last[11];
char first[11];
char address[16];
char city[16];
char state[3];
char zip[10];
} person
14
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Field Structures:
2. Beginning Each Field with a Length
Indicator
 This method requires that each field data
be preceded with an indicator of its length
(in bytes).
 E.G.
04Ames04Mary09123 Maple10StillWater02OK0574075
 One of the disadvantages of this method is that it
is more complex since it requires extracting of
numbers and strings from a single string
representing a record.
15
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Field Structures:
3. Separating Fields with Delimiters
• This method requires that the fields be
separated by a selected special
character or a sequence of characters
called a delimiter.
• E.G. If “|” is used as a delimiter then a
sample record would look like this:
Ames|Mary|123Maple|StillWater|OK|574075|
16
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Field Structures:
4. Using a “keyword = value” expression
 This method requires that each field data be
preceded with the field identifier (keyword).
last=Ames
first=Mary
address=123
Maplecity=StillWater
state=OK
zip=574075
 Can be used with the delimiter method to
mark the field ends.
last=Ames|first=Mary|address=123
Maple|City=StillWater|state=OK|zip=574075
17
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Field Structures:
4. Using a “keyword = value”
expression
• Advantages:
• each field provides information about itself
• good format for dealing with missing fields
• Disadvantages:
• In some application a lot of space may be wasted
on field keywords (up 50%).
18
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML
EXtensible Markup Language
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML
• is a markup language that defines a set of
rules for encoding documents in a format
that is both human-readable and machine-
readable.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
What is XML?
• XML stands for EXtensible Markup Language
• XML is a markup language much like HTML
• XML was designed to describe data
• XML tags are not predefined. You must define your
own tags
• XML uses a Document Type Definition (DTD) or
an XML Schema (XSD) to describe the data
• XML with a DTD or XSD is designed to be self-
descriptive
• XML is a W3C Recommendation.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Simple XML example
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this
weekend!</body>
</note>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
The Main Difference Between XML
and HTML
XML was designed to carry data.
• XML and HTML were designed with
different goals:
– XML was designed to describe data and to
focus on what data is.
– HTML was designed to display data and to
focus on how data looks.
• HTML is about displaying information,
while XML is about describing data.
• XML is not a replacement for HTML.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML is Used to Exchange Data
With XML, data can be exchanged between
incompatible systems
• In the real world, computer systems and databases
contain data in incompatible formats.
• One of the most time-consuming challenges for
developers has been to exchange data between
such systems over the Internet.
• Converting the data to XML can greatly reduce this
complexity and create data that can be read by
many different types of applications.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Can be Used to Share Data
With XML, plain text files can be used to share data
• Since XML data is stored in plain text format, XML
provides a software- and hardware-independent way
of sharing data.
• This makes it much easier to create data that
different applications can work with.
• It also makes it easier to expand or upgrade a
system to new operating systems, servers,
applications, and new browsers
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Can be Used to Store Data
With XML, plain text files can be used to
store data
• XML can also be used to store data in files
or in databases.
• Applications can be written to store and
retrieve information from the store, and
generic applications can be used to
display the data
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Can Make your Data More
Useful
With XML, your data is available to more users.
• Since XML is independent of hardware, software
and application, you can make your data available
to other than only standard HTML browsers.
• Other clients and applications can access your XML
files as data sources, like they are accessing
databases.
• Your data can be made available to all kinds of
"reading machines" (agents), and it is easier to
make your data available for blind people, or people
with other disabilities.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Can be Used to Create New
Languages
XML is the mother of WAP and WML
• The Wireless Markup Language (WML),
used to markup Internet applications for
handheld devices like mobile phones, is
written in XML.
• For a list of XML based languages refer to
wikipedia pages.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Syntax Rules
• The syntax rules of XML are very simple
and very strict.
• The rules are very easy to learn, and very
easy to use.
• Because of this, creating software that can
read and manipulate XML is very easy.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
An Example XML Document
XML documents use a self-describing
and simple syntax
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
All XML Elements Must Have a
Closing Tag
With XML, it is illegal to omit the closing
tag
• In XML all elements must have a closing
tag, like this:
<p>This is a paragraph</p>
<p>This is another paragraph</p>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Tags are Case Sensitive
Unlike HTML, XML tags are case
sensitive
• With XML, the tag <Letter> is different
from the tag <letter>.
• Opening and closing tags must therefore
be written with the same case:
<Message>This is incorrect</message>
<message>This is correct</message>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Elements Must be Properly
Nested
Improper nesting of tags makes no sense to XML
• In HTML some elements can be improperly nested
within each other like this:
• In XML all elements must be properly nested within
each other like this:
<b><i>This text is bold and italic</b></i>
<b><i>This text is bold and italic</i></b>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Documents Must Have a Root
Element
All XML documents must contain a single tag pair
to define a root element
• All other elements must be within this root element.
• All elements can have sub elements (child
elements). Sub elements must be correctly nested
within their parent element:
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Attribute Values Must be
Quoted
With XML, it is illegal to omit quotation marks around attribute
values
<?xml version="1.0" encoding="ISO-8859-1"?>
<note date=12/11/2002>
<to>Tove</to>
<from>Jani</from>
</note>
<?xml version="1.0" encoding="ISO-8859-1"?>
<note date="12/11/2002">
<to>Tove</to>
<from>Jani</from>
</note>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
With XML, White Space is Preserved
• With XML, the white space in your document is
not truncated.
• This is unlike HTML. With HTML, a sentence like
this:
Hello my name is Tove,
will be displayed like this:
Hello my name is Tove,
• because HTML reduces multiple, consecutive white
space characters to a single white space
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
With XML, CR / LF is
Converted to LF
With XML, a new line is always stored as LF
• In Windows applications, a new line is normally
stored as a pair of characters: carriage return (CR)
and line feed (LF).
• The character pair bears some resemblance to the
typewriter actions of setting a new line. In Unix
applications, a new line is normally stored as a LF
character.
• Macintosh applications use only a CR character to
store a new line.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Comments in XML
• The syntax for writing comments in XML is
similar to that of HTML.
<!-- This is a comment -->
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
There is Nothing Special About XML
• It is just plain text with the addition of some XML
tags enclosed in angle brackets.
• Software that can handle plain text can also handle
XML. In a simple text editor, the XML tags will be
visible and will not be handled specially.
• In an XML-aware application however, the XML tags
can be handled specially.
• The tags may or may not be visible, or have a
functional meaning, depending on the nature of the
application.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Elements
• XML Elements are extensible and they
have relationships.
• XML Elements have simple naming rules.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Elements are Extensible
• XML documents can be extended to carry more information.
<note>
<to>Tove</to>
<from>Jani</from>
<body>Don't forget me this weekend!</body>
</note>
MESSAGE
To: Tove
From: Jani
Don't forget me this weekend!
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Elements are Extensible
• XML document added some extra information to it:
MESSAGE
To: Tove
From: Jani
Don't forget me this weekend!
<note>
<date>2002-08-01</date>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Elements have Relationships
• Imagine that this is a description of a book:
My First XML
Introduction to XML
What is HTML
What is XML
XML Syntax
Elements must have a closing tag
Elements must be properly nested
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Elements have Relationships
• Imagine that this XML document describes the book:
<book>
<title>My First XML</title>
<prod id="33-657" media="paper"></prod>
<chapter>Introduction to XML
<para>What is HTML</para>
<para>What is XML</para>
</chapter>
<chapter>XML Syntax
<para>Elements must have a closing tag</para>
<para>Elements must be properly nested</para>
</chapter>
</book>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Elements have Content
Elements can have different content
types.
• An XML element is everything from
(including) the element's start tag to
(including) the element's end tag.
• An element can have element content,
mixed content, simple content, or empty
content. An element can also have
attributes.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Element Naming
XML elements must follow these naming
rules
• Names can contain letters, numbers, and
other characters
• Names must not start with a number or
punctuation character
• Names must not start with the letters xml
(or XML, or Xml, etc)
• Names cannot contain spaces
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Element Naming
Take care when you "invent" element
names and follow these simple rules
• Any name can be used, no words are
reserved, but the idea is to make names
descriptive. Names with an underscore
separator are nice.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Attributes
• XML elements can have attributes in the
start tag, just like HTML.
• Attributes are used to provide additional
information about elements.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Attributes
• XML elements can have attributes.
• From HTML you will remember this: <IMG
SRC="computer.gif">. The SRC attribute provides
additional information about the IMG element.
• In HTML (and in XML) attributes provide additional
information about elements:
<img src="computer.gif">
<a href="demo.asp">
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Attributes
• Attributes often provide information that is
not a part of the data.
• In the example below, the file type is
irrelevant to the data, but important to the
software that wants to manipulate the
element:
<file type="gif">computer.gif</file>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Quote Styles, "female" or 'female'?
• Attribute values must always be enclosed
in quotes, but either single or double
quotes can be used.
• For a person's sex, the person tag can be
written like this:
or
<person sex="female">
<person sex='female'>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Quote Styles in Attributes
• If the attribute value itself contains double quotes it
is necessary to use single quotes, like in this
example:
• If the attribute value itself contains single quotes it is
necessary to use double quotes, like in this
example:
<gangster name='George "Shotgun" Ziegler'>
<gangster name="George 'Shotgun' Ziegler">
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Use of Elements vs. Attributes
• Data can be stored in child elements or in
attributes.
<person sex="female">
<firstname>Anna</firstname>
<lastname>Smith</lastname>
</person>
<person>
<sex>female</sex>
<firstname>Anna</firstname>
<lastname>Smith</lastname>
</person>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Use of Elements vs. Attributes
• Following XML documents contain exactly
the same information:
• Alternative #1
<note date="12/11/2002">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Use of Elements vs. Attributes
• Alternative #2
<note>
<date>12/11/2002</date>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Use of Elements vs. Attributes
• Alternative #3
<note>
<date>
<day>12</day>
<month>11</month>
<year>2002</year>
</date>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Use of Elements vs. Attributes
• Alternative #4
<note day="12" month="11" year="2002“ to="Tove"
from="Jani" heading="Reminder"
body="Don't forget me this weekend!">
</note>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Some of the problems with using
attributes
1. attributes cannot contain multiple values (child
elements can)
2. attributes are not easily expandable (for future
changes)
3. attributes cannot describe structures (child
elements can)
4. attributes are more difficult to manipulate by
program code
5. attribute values are not easy to test against a
Document Type Definition (DTD) - which is used
to define the legal elements of an XML
document
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Use of Elements vs. Attributes
Rule of thumb
• If you use attributes as containers for data,
you end up with documents that are
difficult to read and maintain.
• Try to use elements to describe data.
• Use attributes only to provide information
that is not relevant to the data.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
An Exception to Attribute Rule
 The ID in this example is just a counter, or a
unique identifier, to identify the different notes in
the XML file, and not a part of the note data.
<messages>
<note id="p501">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<note id="p502">
<to>Jani</to>
<from>Tove</from>
<heading>Re: Reminder</heading>
<body>I will not!</body>
</note>
</messages>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Validation
• XML with correct syntax is Well Formed
XML.
• XML validated against a DTD is Valid
XML.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Well Formed XML Documents
A "Well Formed" XML document has
correct XML syntax.
XML documents must have a root element
XML elements must have a closing tag
XML tags are case sensitive
XML elements must be properly nested
XML attribute values must always be
quoted
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Valid XML Documents
A "Valid" XML document also conforms to a DTD
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE note SYSTEM "InternalNote.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML DTD
A DTD defines the legal elements of an
XML document
• The purpose of a DTD is to define the
legal building blocks of an XML document.
• It defines the document structure with a list
of legal elements.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML Schema (XSD)
• XML Schema is an XML based alternative
to DTD
• W3C supports an alternative to DTD called
XML Schema.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
Displaying XML with XSL
• XSL is the preferred style sheet
language of XML
• XSL (the eXtensible Stylesheet Language)
is far more sophisticated than CSS.
• One way to use XSL is to transform XML
into HTML before it is displayed by the
browser as demonstrated in these
examples:
• XML file, the XSL style sheet, and View
the result.
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
XML File
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl"
href="simple.xsl"?>
<breakfast_menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>
two of our famous Belgian Waffles
</description>
<calories>650</calories>
</food>
</breakfast_menu>
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y
D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g
D o k u z E y l ü l U n i v e r s i t y

More Related Content

What's hot

Efficient Query Answering against Dynamic RDF Databases
Efficient Query Answering against Dynamic RDF DatabasesEfficient Query Answering against Dynamic RDF Databases
Efficient Query Answering against Dynamic RDF DatabasesAlexandra Roatiș
 
Fundamental file structure concepts &amp; managing files of records
Fundamental file structure concepts &amp; managing files of recordsFundamental file structure concepts &amp; managing files of records
Fundamental file structure concepts &amp; managing files of recordsDevyani Vaidya
 
non linear data structure -introduction of tree
non linear data structure -introduction of treenon linear data structure -introduction of tree
non linear data structure -introduction of treeSiddhi Viradiya
 
Word Puzzles with Neo4j and Py2neo
Word Puzzles with Neo4j and Py2neoWord Puzzles with Neo4j and Py2neo
Word Puzzles with Neo4j and Py2neoGrant Paton-Simpson
 
Introduction to the design and specification of file structures
Introduction to the design and specification of file structuresIntroduction to the design and specification of file structures
Introduction to the design and specification of file structuresDevyani Vaidya
 
Types of Tree in Data Structure in C++
Types of Tree in Data Structure in C++Types of Tree in Data Structure in C++
Types of Tree in Data Structure in C++Himanshu Choudhary
 
Corpora, Blogs and Linguistic Variation (Paderborn)
Corpora, Blogs and Linguistic Variation (Paderborn)Corpora, Blogs and Linguistic Variation (Paderborn)
Corpora, Blogs and Linguistic Variation (Paderborn)Cornelius Puschmann
 
Unable to retain the table grid with the proper alignment without repaste the...
Unable to retain the table grid with the proper alignment without repaste the...Unable to retain the table grid with the proper alignment without repaste the...
Unable to retain the table grid with the proper alignment without repaste the...Bharat Malge
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanDaniyal Khan
 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for filesZainab Almugbel
 
File Structure Concepts
File Structure ConceptsFile Structure Concepts
File Structure ConceptsDileep Kodira
 
Bca ii dfs u-3 tree and graph
Bca  ii dfs u-3 tree and graphBca  ii dfs u-3 tree and graph
Bca ii dfs u-3 tree and graphRai University
 

What's hot (20)

Efficient Query Answering against Dynamic RDF Databases
Efficient Query Answering against Dynamic RDF DatabasesEfficient Query Answering against Dynamic RDF Databases
Efficient Query Answering against Dynamic RDF Databases
 
Binary Tree Traversal
Binary Tree TraversalBinary Tree Traversal
Binary Tree Traversal
 
Fundamental file structure concepts &amp; managing files of records
Fundamental file structure concepts &amp; managing files of recordsFundamental file structure concepts &amp; managing files of records
Fundamental file structure concepts &amp; managing files of records
 
Files c3
Files c3Files c3
Files c3
 
Chapter 8 ds
Chapter 8 dsChapter 8 ds
Chapter 8 ds
 
non linear data structure -introduction of tree
non linear data structure -introduction of treenon linear data structure -introduction of tree
non linear data structure -introduction of tree
 
Word Puzzles with Neo4j and Py2neo
Word Puzzles with Neo4j and Py2neoWord Puzzles with Neo4j and Py2neo
Word Puzzles with Neo4j and Py2neo
 
Introduction to the design and specification of file structures
Introduction to the design and specification of file structuresIntroduction to the design and specification of file structures
Introduction to the design and specification of file structures
 
Types of Tree in Data Structure in C++
Types of Tree in Data Structure in C++Types of Tree in Data Structure in C++
Types of Tree in Data Structure in C++
 
Corpora, Blogs and Linguistic Variation (Paderborn)
Corpora, Blogs and Linguistic Variation (Paderborn)Corpora, Blogs and Linguistic Variation (Paderborn)
Corpora, Blogs and Linguistic Variation (Paderborn)
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Tree
TreeTree
Tree
 
Music Therapy Bi Fall 2005
Music Therapy Bi Fall 2005Music Therapy Bi Fall 2005
Music Therapy Bi Fall 2005
 
Unable to retain the table grid with the proper alignment without repaste the...
Unable to retain the table grid with the proper alignment without repaste the...Unable to retain the table grid with the proper alignment without repaste the...
Unable to retain the table grid with the proper alignment without repaste the...
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal Khan
 
File handling
File handlingFile handling
File handling
 
Indexing structure for files
Indexing structure for filesIndexing structure for files
Indexing structure for files
 
File Structure Concepts
File Structure ConceptsFile Structure Concepts
File Structure Concepts
 
ADBMS DATATYPES
ADBMS DATATYPESADBMS DATATYPES
ADBMS DATATYPES
 
Bca ii dfs u-3 tree and graph
Bca  ii dfs u-3 tree and graphBca  ii dfs u-3 tree and graph
Bca ii dfs u-3 tree and graph
 

Viewers also liked

시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매 , 시알리스 발기제종류, 시알리스 발기제 사용후기...
시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매 , 시알리스 발기제종류, 시알리스 발기제 사용후기...시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매 , 시알리스 발기제종류, 시알리스 발기제 사용후기...
시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매 , 시알리스 발기제종류, 시알리스 발기제 사용후기...무우 단
 
Methods to Measure Obesity
Methods to Measure ObesityMethods to Measure Obesity
Methods to Measure ObesityDr. Eric Gan
 
시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제약효,시알리스 발기제구입처,시알리스...
시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제약효,시알리스 발기제구입처,시알리스...시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제약효,시알리스 발기제구입처,시알리스...
시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제약효,시알리스 발기제구입처,시알리스...무우 단
 
시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제가격,시알리스 발기제판매,시알리스 ...
시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제가격,시알리스 발기제판매,시알리스 ...시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제가격,시알리스 발기제판매,시알리스 ...
시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제가격,시알리스 발기제판매,시알리스 ...무우 단
 
ERT TINGKATAN 5 BAB 3
ERT TINGKATAN 5 BAB 3ERT TINGKATAN 5 BAB 3
ERT TINGKATAN 5 BAB 3Norliza Yusof
 
Robustness of classifiers_from_adversarial_to_random_noise
Robustness of classifiers_from_adversarial_to_random_noiseRobustness of classifiers_from_adversarial_to_random_noise
Robustness of classifiers_from_adversarial_to_random_noiseKeisuke Hosaka
 
Generative adversarial nets
Generative adversarial netsGenerative adversarial nets
Generative adversarial netsKeisuke Hosaka
 
ERT TINGKATAN 5 BAB 1
ERT TINGKATAN 5 BAB 1ERT TINGKATAN 5 BAB 1
ERT TINGKATAN 5 BAB 1Norliza Yusof
 
2. Jesús se Separa de su Madre Santísima ( 6-7 p.m.)
2. Jesús se Separa de su Madre Santísima ( 6-7 p.m.)2. Jesús se Separa de su Madre Santísima ( 6-7 p.m.)
2. Jesús se Separa de su Madre Santísima ( 6-7 p.m.)Lorena Gomez
 
1. Jesús se despide de su Madre (5-6 pm)
1. Jesús se despide de su Madre (5-6 pm)1. Jesús se despide de su Madre (5-6 pm)
1. Jesús se despide de su Madre (5-6 pm)Lorena Gomez
 
Kaggle bosch presentation material for Kaggle Tokyo Meetup #2
Kaggle bosch presentation material for Kaggle Tokyo Meetup #2Kaggle bosch presentation material for Kaggle Tokyo Meetup #2
Kaggle bosch presentation material for Kaggle Tokyo Meetup #2Keisuke Hosaka
 
Kaggle boschコンペ振り返り
Kaggle boschコンペ振り返りKaggle boschコンペ振り返り
Kaggle boschコンペ振り返りKeisuke Hosaka
 
Hyperoptとその周辺について
Hyperoptとその周辺についてHyperoptとその周辺について
Hyperoptとその周辺についてKeisuke Hosaka
 
Corporate Presentation Feb 2017
Corporate Presentation Feb 2017Corporate Presentation Feb 2017
Corporate Presentation Feb 2017Stornoway Diamonds
 
10. XML in DBMS
10. XML in DBMS10. XML in DBMS
10. XML in DBMSkoolkampus
 

Viewers also liked (20)

시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매 , 시알리스 발기제종류, 시알리스 발기제 사용후기...
시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매 , 시알리스 발기제종류, 시알리스 발기제 사용후기...시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매 , 시알리스 발기제종류, 시알리스 발기제 사용후기...
시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매 , 시알리스 발기제종류, 시알리스 발기제 사용후기...
 
XML
XMLXML
XML
 
Methods to Measure Obesity
Methods to Measure ObesityMethods to Measure Obesity
Methods to Measure Obesity
 
시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제약효,시알리스 발기제구입처,시알리스...
시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제약효,시알리스 발기제구입처,시알리스...시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제약효,시알리스 발기제구입처,시알리스...
시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제약효,시알리스 발기제구입처,시알리스...
 
시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제가격,시알리스 발기제판매,시알리스 ...
시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제가격,시알리스 발기제판매,시알리스 ...시알리스 발기제『 http://x6.na.to  』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제가격,시알리스 발기제판매,시알리스 ...
시알리스 발기제『 http://x6.na.to 』 톡 w2015 ♡ 시알리스 발기제판매,시알리스 발기제가격,시알리스 발기제판매,시알리스 ...
 
Internet y redes sociales
Internet y redes socialesInternet y redes sociales
Internet y redes sociales
 
ERT TINGKATAN 5 BAB 3
ERT TINGKATAN 5 BAB 3ERT TINGKATAN 5 BAB 3
ERT TINGKATAN 5 BAB 3
 
Robustness of classifiers_from_adversarial_to_random_noise
Robustness of classifiers_from_adversarial_to_random_noiseRobustness of classifiers_from_adversarial_to_random_noise
Robustness of classifiers_from_adversarial_to_random_noise
 
Expresión Oral
Expresión OralExpresión Oral
Expresión Oral
 
Generative adversarial nets
Generative adversarial netsGenerative adversarial nets
Generative adversarial nets
 
ERT TINGKATAN 5 BAB 1
ERT TINGKATAN 5 BAB 1ERT TINGKATAN 5 BAB 1
ERT TINGKATAN 5 BAB 1
 
2. Jesús se Separa de su Madre Santísima ( 6-7 p.m.)
2. Jesús se Separa de su Madre Santísima ( 6-7 p.m.)2. Jesús se Separa de su Madre Santísima ( 6-7 p.m.)
2. Jesús se Separa de su Madre Santísima ( 6-7 p.m.)
 
From mcmc to sgnht
From mcmc to sgnhtFrom mcmc to sgnht
From mcmc to sgnht
 
1. Jesús se despide de su Madre (5-6 pm)
1. Jesús se despide de su Madre (5-6 pm)1. Jesús se despide de su Madre (5-6 pm)
1. Jesús se despide de su Madre (5-6 pm)
 
Kaggle bosch presentation material for Kaggle Tokyo Meetup #2
Kaggle bosch presentation material for Kaggle Tokyo Meetup #2Kaggle bosch presentation material for Kaggle Tokyo Meetup #2
Kaggle bosch presentation material for Kaggle Tokyo Meetup #2
 
Kaggle boschコンペ振り返り
Kaggle boschコンペ振り返りKaggle boschコンペ振り返り
Kaggle boschコンペ振り返り
 
Hyperoptとその周辺について
Hyperoptとその周辺についてHyperoptとその周辺について
Hyperoptとその周辺について
 
Corporate Presentation Feb 2017
Corporate Presentation Feb 2017Corporate Presentation Feb 2017
Corporate Presentation Feb 2017
 
10. XML in DBMS
10. XML in DBMS10. XML in DBMS
10. XML in DBMS
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 

Similar to XML Introduction Lecture on Data Organization and Management

Similar to XML Introduction Lecture on Data Organization and Management (20)

INSPIRE Registers
INSPIRE RegistersINSPIRE Registers
INSPIRE Registers
 
3. ldap
3. ldap3. ldap
3. ldap
 
XML
XMLXML
XML
 
Introduction to XML.ppt
Introduction to XML.pptIntroduction to XML.ppt
Introduction to XML.ppt
 
Introduction to XML.ppt
Introduction to XML.pptIntroduction to XML.ppt
Introduction to XML.ppt
 
DS.pptx
DS.pptxDS.pptx
DS.pptx
 
Xml unit1
Xml unit1Xml unit1
Xml unit1
 
Data structures
Data structuresData structures
Data structures
 
Normalizing Data for Migrations
Normalizing Data for MigrationsNormalizing Data for Migrations
Normalizing Data for Migrations
 
Oracle sql in 7 days by suesh.n v 1.0
Oracle sql in 7 days by suesh.n v 1.0Oracle sql in 7 days by suesh.n v 1.0
Oracle sql in 7 days by suesh.n v 1.0
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Different string operations....................
Different string operations....................Different string operations....................
Different string operations....................
 
EXTENSIBLE MARKUP LANGUAGE BY SAIKIRAN PANJALA
EXTENSIBLE MARKUP LANGUAGE BY SAIKIRAN PANJALAEXTENSIBLE MARKUP LANGUAGE BY SAIKIRAN PANJALA
EXTENSIBLE MARKUP LANGUAGE BY SAIKIRAN PANJALA
 
XML: A New Standard for Data
XML: A New Standard for DataXML: A New Standard for Data
XML: A New Standard for Data
 
Elasticsearch at EyeEm
Elasticsearch at EyeEmElasticsearch at EyeEm
Elasticsearch at EyeEm
 
Digital Twin: jSON-LD, RDF
Digital Twin: jSON-LD, RDFDigital Twin: jSON-LD, RDF
Digital Twin: jSON-LD, RDF
 
Data dictionary
Data dictionaryData dictionary
Data dictionary
 
Text Mining
Text MiningText Mining
Text Mining
 
Introduction to XML Technology
Introduction to XML TechnologyIntroduction to XML Technology
Introduction to XML Technology
 
Profile of NPOESS HDF5 Files
Profile of NPOESS HDF5 FilesProfile of NPOESS HDF5 Files
Profile of NPOESS HDF5 Files
 

More from Adil Alpkoçak

Expert Systems vs Clinical Decision Support Systems
Expert Systems vs Clinical Decision Support SystemsExpert Systems vs Clinical Decision Support Systems
Expert Systems vs Clinical Decision Support SystemsAdil Alpkoçak
 
Fotografcilikta Minimalizm (iFOD)
Fotografcilikta Minimalizm (iFOD)Fotografcilikta Minimalizm (iFOD)
Fotografcilikta Minimalizm (iFOD)Adil Alpkoçak
 
Socialnetworkanalysis 100225055227-phpapp02
Socialnetworkanalysis 100225055227-phpapp02Socialnetworkanalysis 100225055227-phpapp02
Socialnetworkanalysis 100225055227-phpapp02Adil Alpkoçak
 
Fotoğrafçılıkta Minimalizm
Fotoğrafçılıkta MinimalizmFotoğrafçılıkta Minimalizm
Fotoğrafçılıkta MinimalizmAdil Alpkoçak
 

More from Adil Alpkoçak (7)

Expert Systems vs Clinical Decision Support Systems
Expert Systems vs Clinical Decision Support SystemsExpert Systems vs Clinical Decision Support Systems
Expert Systems vs Clinical Decision Support Systems
 
Fotografcilikta Minimalizm (iFOD)
Fotografcilikta Minimalizm (iFOD)Fotografcilikta Minimalizm (iFOD)
Fotografcilikta Minimalizm (iFOD)
 
Socialnetworkanalysis 100225055227-phpapp02
Socialnetworkanalysis 100225055227-phpapp02Socialnetworkanalysis 100225055227-phpapp02
Socialnetworkanalysis 100225055227-phpapp02
 
Lecture#5
Lecture#5Lecture#5
Lecture#5
 
Lecture#01
Lecture#01Lecture#01
Lecture#01
 
Mir lecture1
Mir lecture1Mir lecture1
Mir lecture1
 
Fotoğrafçılıkta Minimalizm
Fotoğrafçılıkta MinimalizmFotoğrafçılıkta Minimalizm
Fotoğrafçılıkta Minimalizm
 

Recently uploaded

Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 

Recently uploaded (20)

Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 

XML Introduction Lecture on Data Organization and Management

  • 1. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g Lecture #2 XML Introduction Dr.Adil Alpkocak Dokuz Eylul University Dept of Computer Engineering CME2002 Data Organization and Management
  • 2. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Today • Field and record organization • XML introduction 2
  • 3. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Files A file can be seen as 1. A stream of bytes (no structure), or 2. A collection of records with fields 3
  • 4. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y #1. File as stream bytes • File is viewed as a sequence of bytes: • Data semantics is lost: there is no way to get it apart again. 4 87359CarrollAlice in wonderland38180FolkFile Structures ...
  • 5. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y #2: File as a Collection of Records Definitions File: Collection of records. Record: a collection of related fields. Field: the smallest logically meaningful unit of information in a file. Key: a subset of the fields in a record used to identify (uniquely) the record. e.g. In the example file of books: – Each line corresponds to a record. – Fields in each record: ISBN, Author, Title 5
  • 6. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Different Notation column row Table Field Record File Attribute Tuple Relation Terms in the same column are synonyms, and can be used interchangeably.
  • 7. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Record Keys • Primary key: a key that uniquely identifies a record. • Secondary key: other keys that may be used for search – Author name – Book title – Author name + book title • Note that in general not every field is a key (keys correspond to fields, or a combination of fields, that may be used in a search). 7
  • 8. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Record Structures 1. Fixed-length records. 2. Fixed number of fields. 3. Begin each record with a length indicator. 4. Use an index to keep track of addresses. 5. Place a delimiter at the end of the record. 8
  • 9. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y 1.Fixed-length records Two ways of making fixed-length records: 1. Fixed-length records with fixed-length fields. 2. Fixed-length records with variable- length fields. 9 87359 Carroll Alice in wonderland 03818 Folk File Structures 87359|Carroll|Alice in wonderland| unused 38180|Folk|File Structures| unused
  • 10. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Fixed-Length Records • e.g. struct PERSON { char last[11]; char first[11]; char address[16]; char city[16]; char state[3]; char zip[10]; } person; Will produce a fixed size record of size 67 bytes. 10
  • 11. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Fixed-Length Records • The fixed length record structure, however, does NOT imply, the fixed - length field structure. • Fixed-length records are frequently used as “containers” to hold variable numbers of variable-length fields. • Fixed-length record structures are among the most commonly used methods for organizing files. 11
  • 12. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Variable-length records 2. Fixed number of fields: 3. Record beginning with length indicator: 4. Use an index file to keep track of record addresses: – The index file keeps the byte offset for each record; this allows us to search the index (which have fixed length records) in order to discover the beginning of the record. 5. Placing a delimiter: e.g. end-of-line char 12 87359|Carroll|Alice in wonderland|38180|Folk|File Structures| ... 3387359|Carroll|Alice in wonderland|2638180|Folk|File Structures| ..
  • 13. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Field Structures 1. Fixed-length fields 87359Carroll Alice in wonderland 38180Folk File Structures 2. Begin each field with a length indicator 058735907Carroll19Alice in wonderland 053818004Folk15File Structures 3. Place a delimiter at the end of each field 87359|Carroll|Alice in wonderland| 38180|Folk|File Structures| 4. Store field as keyword = value ISBN=87359|AU=Carroll|TI=Alice in wonderland| ISBN=38180|AU=Folk|TI=File Structures 13
  • 14. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Field Structures: 1. Fixing the Length of Fields This method relies on creating fields of predictable fixed size. struct PERSON { char last[11]; char first[11]; char address[16]; char city[16]; char state[3]; char zip[10]; } person 14
  • 15. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Field Structures: 2. Beginning Each Field with a Length Indicator  This method requires that each field data be preceded with an indicator of its length (in bytes).  E.G. 04Ames04Mary09123 Maple10StillWater02OK0574075  One of the disadvantages of this method is that it is more complex since it requires extracting of numbers and strings from a single string representing a record. 15
  • 16. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Field Structures: 3. Separating Fields with Delimiters • This method requires that the fields be separated by a selected special character or a sequence of characters called a delimiter. • E.G. If “|” is used as a delimiter then a sample record would look like this: Ames|Mary|123Maple|StillWater|OK|574075| 16
  • 17. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Field Structures: 4. Using a “keyword = value” expression  This method requires that each field data be preceded with the field identifier (keyword). last=Ames first=Mary address=123 Maplecity=StillWater state=OK zip=574075  Can be used with the delimiter method to mark the field ends. last=Ames|first=Mary|address=123 Maple|City=StillWater|state=OK|zip=574075 17
  • 18. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Field Structures: 4. Using a “keyword = value” expression • Advantages: • each field provides information about itself • good format for dealing with missing fields • Disadvantages: • In some application a lot of space may be wasted on field keywords (up 50%). 18
  • 19. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML EXtensible Markup Language
  • 20. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML • is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine- readable.
  • 21. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y What is XML? • XML stands for EXtensible Markup Language • XML is a markup language much like HTML • XML was designed to describe data • XML tags are not predefined. You must define your own tags • XML uses a Document Type Definition (DTD) or an XML Schema (XSD) to describe the data • XML with a DTD or XSD is designed to be self- descriptive • XML is a W3C Recommendation.
  • 22. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Simple XML example <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
  • 23. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y The Main Difference Between XML and HTML XML was designed to carry data. • XML and HTML were designed with different goals: – XML was designed to describe data and to focus on what data is. – HTML was designed to display data and to focus on how data looks. • HTML is about displaying information, while XML is about describing data. • XML is not a replacement for HTML.
  • 24. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML is Used to Exchange Data With XML, data can be exchanged between incompatible systems • In the real world, computer systems and databases contain data in incompatible formats. • One of the most time-consuming challenges for developers has been to exchange data between such systems over the Internet. • Converting the data to XML can greatly reduce this complexity and create data that can be read by many different types of applications.
  • 25. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Can be Used to Share Data With XML, plain text files can be used to share data • Since XML data is stored in plain text format, XML provides a software- and hardware-independent way of sharing data. • This makes it much easier to create data that different applications can work with. • It also makes it easier to expand or upgrade a system to new operating systems, servers, applications, and new browsers
  • 26. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Can be Used to Store Data With XML, plain text files can be used to store data • XML can also be used to store data in files or in databases. • Applications can be written to store and retrieve information from the store, and generic applications can be used to display the data
  • 27. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Can Make your Data More Useful With XML, your data is available to more users. • Since XML is independent of hardware, software and application, you can make your data available to other than only standard HTML browsers. • Other clients and applications can access your XML files as data sources, like they are accessing databases. • Your data can be made available to all kinds of "reading machines" (agents), and it is easier to make your data available for blind people, or people with other disabilities.
  • 28. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Can be Used to Create New Languages XML is the mother of WAP and WML • The Wireless Markup Language (WML), used to markup Internet applications for handheld devices like mobile phones, is written in XML. • For a list of XML based languages refer to wikipedia pages.
  • 29. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Syntax Rules • The syntax rules of XML are very simple and very strict. • The rules are very easy to learn, and very easy to use. • Because of this, creating software that can read and manipulate XML is very easy.
  • 30. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y An Example XML Document XML documents use a self-describing and simple syntax <?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
  • 31. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y All XML Elements Must Have a Closing Tag With XML, it is illegal to omit the closing tag • In XML all elements must have a closing tag, like this: <p>This is a paragraph</p> <p>This is another paragraph</p>
  • 32. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Tags are Case Sensitive Unlike HTML, XML tags are case sensitive • With XML, the tag <Letter> is different from the tag <letter>. • Opening and closing tags must therefore be written with the same case: <Message>This is incorrect</message> <message>This is correct</message>
  • 33. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Elements Must be Properly Nested Improper nesting of tags makes no sense to XML • In HTML some elements can be improperly nested within each other like this: • In XML all elements must be properly nested within each other like this: <b><i>This text is bold and italic</b></i> <b><i>This text is bold and italic</i></b>
  • 34. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Documents Must Have a Root Element All XML documents must contain a single tag pair to define a root element • All other elements must be within this root element. • All elements can have sub elements (child elements). Sub elements must be correctly nested within their parent element: <root> <child> <subchild>.....</subchild> </child> </root>
  • 35. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Attribute Values Must be Quoted With XML, it is illegal to omit quotation marks around attribute values <?xml version="1.0" encoding="ISO-8859-1"?> <note date=12/11/2002> <to>Tove</to> <from>Jani</from> </note> <?xml version="1.0" encoding="ISO-8859-1"?> <note date="12/11/2002"> <to>Tove</to> <from>Jani</from> </note>
  • 36. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y With XML, White Space is Preserved • With XML, the white space in your document is not truncated. • This is unlike HTML. With HTML, a sentence like this: Hello my name is Tove, will be displayed like this: Hello my name is Tove, • because HTML reduces multiple, consecutive white space characters to a single white space
  • 37. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y With XML, CR / LF is Converted to LF With XML, a new line is always stored as LF • In Windows applications, a new line is normally stored as a pair of characters: carriage return (CR) and line feed (LF). • The character pair bears some resemblance to the typewriter actions of setting a new line. In Unix applications, a new line is normally stored as a LF character. • Macintosh applications use only a CR character to store a new line.
  • 38. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Comments in XML • The syntax for writing comments in XML is similar to that of HTML. <!-- This is a comment -->
  • 39. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y There is Nothing Special About XML • It is just plain text with the addition of some XML tags enclosed in angle brackets. • Software that can handle plain text can also handle XML. In a simple text editor, the XML tags will be visible and will not be handled specially. • In an XML-aware application however, the XML tags can be handled specially. • The tags may or may not be visible, or have a functional meaning, depending on the nature of the application.
  • 40. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Elements • XML Elements are extensible and they have relationships. • XML Elements have simple naming rules.
  • 41. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Elements are Extensible • XML documents can be extended to carry more information. <note> <to>Tove</to> <from>Jani</from> <body>Don't forget me this weekend!</body> </note> MESSAGE To: Tove From: Jani Don't forget me this weekend!
  • 42. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Elements are Extensible • XML document added some extra information to it: MESSAGE To: Tove From: Jani Don't forget me this weekend! <note> <date>2002-08-01</date> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
  • 43. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Elements have Relationships • Imagine that this is a description of a book: My First XML Introduction to XML What is HTML What is XML XML Syntax Elements must have a closing tag Elements must be properly nested
  • 44. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Elements have Relationships • Imagine that this XML document describes the book: <book> <title>My First XML</title> <prod id="33-657" media="paper"></prod> <chapter>Introduction to XML <para>What is HTML</para> <para>What is XML</para> </chapter> <chapter>XML Syntax <para>Elements must have a closing tag</para> <para>Elements must be properly nested</para> </chapter> </book>
  • 45. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Elements have Content Elements can have different content types. • An XML element is everything from (including) the element's start tag to (including) the element's end tag. • An element can have element content, mixed content, simple content, or empty content. An element can also have attributes.
  • 46. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Element Naming XML elements must follow these naming rules • Names can contain letters, numbers, and other characters • Names must not start with a number or punctuation character • Names must not start with the letters xml (or XML, or Xml, etc) • Names cannot contain spaces
  • 47. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Element Naming Take care when you "invent" element names and follow these simple rules • Any name can be used, no words are reserved, but the idea is to make names descriptive. Names with an underscore separator are nice.
  • 48. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Attributes • XML elements can have attributes in the start tag, just like HTML. • Attributes are used to provide additional information about elements.
  • 49. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Attributes • XML elements can have attributes. • From HTML you will remember this: <IMG SRC="computer.gif">. The SRC attribute provides additional information about the IMG element. • In HTML (and in XML) attributes provide additional information about elements: <img src="computer.gif"> <a href="demo.asp">
  • 50. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Attributes • Attributes often provide information that is not a part of the data. • In the example below, the file type is irrelevant to the data, but important to the software that wants to manipulate the element: <file type="gif">computer.gif</file>
  • 51. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Quote Styles, "female" or 'female'? • Attribute values must always be enclosed in quotes, but either single or double quotes can be used. • For a person's sex, the person tag can be written like this: or <person sex="female"> <person sex='female'>
  • 52. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Quote Styles in Attributes • If the attribute value itself contains double quotes it is necessary to use single quotes, like in this example: • If the attribute value itself contains single quotes it is necessary to use double quotes, like in this example: <gangster name='George "Shotgun" Ziegler'> <gangster name="George 'Shotgun' Ziegler">
  • 53. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Use of Elements vs. Attributes • Data can be stored in child elements or in attributes. <person sex="female"> <firstname>Anna</firstname> <lastname>Smith</lastname> </person> <person> <sex>female</sex> <firstname>Anna</firstname> <lastname>Smith</lastname> </person>
  • 54. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Use of Elements vs. Attributes • Following XML documents contain exactly the same information: • Alternative #1 <note date="12/11/2002"> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
  • 55. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Use of Elements vs. Attributes • Alternative #2 <note> <date>12/11/2002</date> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
  • 56. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Use of Elements vs. Attributes • Alternative #3 <note> <date> <day>12</day> <month>11</month> <year>2002</year> </date> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
  • 57. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Use of Elements vs. Attributes • Alternative #4 <note day="12" month="11" year="2002“ to="Tove" from="Jani" heading="Reminder" body="Don't forget me this weekend!"> </note>
  • 58. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Some of the problems with using attributes 1. attributes cannot contain multiple values (child elements can) 2. attributes are not easily expandable (for future changes) 3. attributes cannot describe structures (child elements can) 4. attributes are more difficult to manipulate by program code 5. attribute values are not easy to test against a Document Type Definition (DTD) - which is used to define the legal elements of an XML document
  • 59. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Use of Elements vs. Attributes Rule of thumb • If you use attributes as containers for data, you end up with documents that are difficult to read and maintain. • Try to use elements to describe data. • Use attributes only to provide information that is not relevant to the data.
  • 60. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y An Exception to Attribute Rule  The ID in this example is just a counter, or a unique identifier, to identify the different notes in the XML file, and not a part of the note data. <messages> <note id="p501"> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> <note id="p502"> <to>Jani</to> <from>Tove</from> <heading>Re: Reminder</heading> <body>I will not!</body> </note> </messages>
  • 61. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Validation • XML with correct syntax is Well Formed XML. • XML validated against a DTD is Valid XML.
  • 62. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Well Formed XML Documents A "Well Formed" XML document has correct XML syntax. XML documents must have a root element XML elements must have a closing tag XML tags are case sensitive XML elements must be properly nested XML attribute values must always be quoted
  • 63. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Valid XML Documents A "Valid" XML document also conforms to a DTD <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE note SYSTEM "InternalNote.dtd"> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
  • 64. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML DTD A DTD defines the legal elements of an XML document • The purpose of a DTD is to define the legal building blocks of an XML document. • It defines the document structure with a list of legal elements.
  • 65. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML Schema (XSD) • XML Schema is an XML based alternative to DTD • W3C supports an alternative to DTD called XML Schema.
  • 66. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y Displaying XML with XSL • XSL is the preferred style sheet language of XML • XSL (the eXtensible Stylesheet Language) is far more sophisticated than CSS. • One way to use XSL is to transform XML into HTML before it is displayed by the browser as demonstrated in these examples: • XML file, the XSL style sheet, and View the result.
  • 67. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y XML File <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="simple.xsl"?> <breakfast_menu> <food> <name>Belgian Waffles</name> <price>$5.95</price> <description> two of our famous Belgian Waffles </description> <calories>650</calories> </food> </breakfast_menu>
  • 68. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y
  • 69. D e p a r t m e n t o f C o m p u t e r E n g i n e e r i n g D o k u z E y l ü l U n i v e r s i t y