by mohsen ashouri. introduction comparison between xml and html xml syntax challenges summary

17
By Mohsen ashouri

Upload: bruno-lewis

Post on 01-Jan-2016

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

ByMohsen ashouri

Page 2: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

Introduction Comparison between XML and HTML XML Syntax Challenges Summary

Page 3: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

eXtensible Markup Language Based on Standard Generalized Markup

Language (SGML) Version 1.0 introduced by World Wide

Web Consortium (W3C) in 1998 Bridge for data exchange on

the Web

Page 4: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

Extensible set of tags

Content orientated errors are not

allowed Allows multiple

output forms

Fixed set of tags Presentation

oriented Ignore many HTML

errors Single presentation

XML HTML

Page 5: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

An XML element is made up of a start tag, an end tag, and data in between.

Example: <director> Majid Majidi </director> Example of another element with the same value: <actor> Parviz Parastooi</actor> XML tags are case-sensitive: <CITY> <City> <city> XML can abbreviate empty elements, for example: <Book> </Book> can be abbreviated to <Book/>

Page 6: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

An attribute is a name-value pair separated by an equal sign (=).

Example: <City City_IP=“94608”> Isfahan

</City> Attributes are used to attach additional,

secondary information to an element.

Page 7: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

A basic XML document is an XML element that can, but might not, include nested XML elements.

Example: <books> <book isbn=“123”> <title> Second Chance </title> <author> Matthew Dunn

</author> </book> </books>

Page 8: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

<BOOKS><book id=“123”

loc=“library”> <author>Hull</author> <title>California</title> <year> 1995 </year></book><article id=“555”

ref=“123”> <author>Su</author> <title>

Venezuela</title></article></BOOKS> Hull Purdue

BOOKS

123 555

California

Su

titleauthor

title

author

articlebook

year

1995

ref

loc=“library”

Page 9: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

Authoring guidelines:› All elements must have an end tag.

› Elements must be properly nested, e.g. not

<book><title>book and title</book></title>

› All attribute values must be enclosed in quotation marks.

› Each document must have a unique first element, the root node.

Page 10: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

Comments can be put anywhere in an XML document

Comments are not elements and do not have an end tag

The blanks after <!-- and before --> are optional The closing bracket must be --> Comments are not displayed by browsers, but can

be seen by anyone who looks at the source code Example : <!-- This is a comment in both HTML and XML

-->

Page 11: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

An XML document may have an optional DTD.

DTD serves as grammar for the underlying XML document, and it is part of XML language.

DTDs are somewhat unsatisfactory, but no consensus exists so far beyond the basic DTDs.

DTD has the form: <!DOCTYPE root [markupdeclaration]>

Page 12: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

Consider an XML document:

<db> <person> <name>Ali</name> <age>42</age> <email>[email protected]

</email> </person> <person>………</person> ………. </db>

db

Person

42

age

name email

[email protected]

Person

Person

ali

Page 13: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

DTD for it might be: <!DOCTYPE db [ <!ELEMENT db (person*)> <!ELEMENT person (name, age,

email)> <!ELEMENT name (#PCDATA)> <!ELEMENT age (#PCDATA)> <!ELEMENT email (#PCDATA)> ]>

Page 14: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

If the elements within your document must appear in a distinct order, you should define your content model using a sequence.

To achieve this, simply list the element names separated by commas.

Example:› <!ELEMENT name (first, middle,

last)>

Page 15: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

Example:› <!ELEMENT item (CD| cassette| record|MP3)>

› This declaration mandates that we would allow our <item> element to contain one <cd> or one <cassette> or one <record> or one <MP3>

› If <item> element were empty, or if it contained more than one of these the parser would raise an error.

Page 16: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

Occurrence Indicator:

Indicator Occurrence

(no indicator) Required One and only one

? Optional None or one

* Optional, repeatable

None, one, or more

+ Required, repeatable

One or more

Page 17: By Mohsen ashouri.  Introduction  Comparison between XML and HTML  XML Syntax  Challenges  Summary

Learn XML – Persian Language

Security