Chapter 5 XML
Chapter 5 XML
Chapter 5 XML
1
Why XML ?
2
What is XML ?
3
The Basic Rules
4
Encoding
5
Example :
<?xml version = “1.0” ?>
<address>
<name>
<first>Mohammed </first>
<last>Ali</last>
</name>
<email>[email protected]</email>
<phone>05278743</phone>
<birthday>
<year>2001</year>
<month>01</month>
<day>09</day>
</birthday>
</address>
6
XML Files are Trees
address
7
HTML vs XML
9
DTD : Document Type Definitions
• A DTD describes the tree structure of a document and something
about its data.
• A DTD determines how many times a node may appear, and how
child nodes are ordered.
10
DTD for address Example
11
Schemas
12
Schema for First address Example
13
XSLT
Extensible Stylesheet Language Transformations
14
A Style Sheet to Transform address.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/
XSL/Transform">
<xsl:template match="address">
<html><head><title>Address Book</title></head>
<body>
<xsl:value-of select="name"/>
<br/><xsl:value-of select="email"/>
<br/><xsl:value-of select="phone"/>
<br/><xsl:value-of select="birthday"/>
</body>
</html>
</xsl:template> Result :
</xsl:stylesheet> AMU MCA
[email protected]
123-45-6789
15
1920-01-09
Parsers
16
Advantages of XML
XML file sizes are usually very large due to its verbose
nature, it is totally dependent on who is writing it.
18