UNIT%205.%20Introduction%20to%20Computer%20Networks - PowerPoint PPT Presentation

About This Presentation
Title:

UNIT%205.%20Introduction%20to%20Computer%20Networks

Description:

Title: Unit 1.3 File Systems Author: linfeng Last modified by: linfeng Created Date: 1/15/2002 1:14:05 AM Document presentation format: (4:3) – PowerPoint PPT presentation

Number of Views:169
Avg rating:3.0/5.0
Slides: 111
Provided by: linf153
Category:

less

Transcript and Presenter's Notes

Title: UNIT%205.%20Introduction%20to%20Computer%20Networks


1
UNIT 5. Introduction to Computer Networks
  • Feng Lin
  • Sichuan Univ.

2
Outline
  • Unit 5.1 Basic of Internet
  • Unit 5.2 More on Computer Networks
  • Unit 5.3 Network Architecture

3
About me
  • Dr. Feng Lin
  • Course Email linfengscu_at_gmail.com
  • Class Hours 6 Lecture hours 6 Lab hours
  • My Office RM 325, Building B, Jichujiaoxue
    Hall,
  • Wangjiang Campus.
  • (?????????B?325)
  • Office Hours 900 AM 1130 AM, Fri.

4
Unit 5.1 Basic of Internet
5
Agenda
  • First Sight of Communication
  • Everything is Connected to Everything
  • Applications of Internet
  • Web
  • Email
  • Classification of Computer Networks
  • Transmission Media
  • LAN,MAN,WAN
  • Client/Sever vs Peer to Peer

6
First Sight of Communication
  • The human need to communicate has motivated
    mankinds creativity
  • Cave dwellers drew pictures on walls.
  • Smoke signals, drum rhythms passed messages.
  • Postal service a system for physically
    transporting documents and other small packages
  • Alexander Graham Bell invented the telephone.
  • Data Communication
  • Data communications are the exchange of data
    between two devices via some form of transmission
    medium

7
  • What is needed for successful communications?

8
Everything is Connected to Everything
  • Computer Network A collection of computers,
    display terminals, printers, and other devices
    linked either by physical or wireless means.
  • Seeds of Networking
  • 1966 ARPA (Advanced Research Projects Agency)
    State Defense Departments research organization.
  • Focused major development effort on computer
    networking.
  • ARPAs Goal To promote research in advanced
    future technologies by funding university and
    industry research proposals.
  • Result Thousands of databases became available
    to the public.

9
Everything is Connected to Everything
  • Computer Networking
  • Internet A world-wide network connecting
    millions of computer networks for the purpose of
    exchanging data and communications using special
    rules of communication.
  • internet (lower case i) Any network connecting
    two or more computer networks.
  • Going online Connecting to a collection of
    interconnected computers on a network.
  • Do banking.
  • Pay bills.
  • Buy groceries.
  • Book vacation travel.
  • Send messages.
  • Participate in discussions.
  • Do research.
  • Play games.

10
Everything is Connected to Everything
Web
E-Mail
InstantMessaging
Internet Telephony
Newsgroups
Chat Rooms
WebFolders
Fax Machine or Computer Fax/Modem
VideoConferencing
FTP
11
Internet Basics
  • The Internet Backbone
  • Major internet communication links.
  • Network/Internet service provider (NSP/ISP)
  • Construct and maintain the Internet backbone,
    such as ATT
  • Network access point (NAP) point on the
    Internet where several connections converge

12
Nation-wide Internet Service Providers in China
  • There are four Nation-wide Internet Service
    Providers in China
  • CERNET China Education and Research Network
  • CSTNET China Science and Technology Network
  • CHINANET China Public Computer Internet
  • GBNNET Golden Bridge Information Network
  • To be permitted to connect with Internet backbone
    directly

13
Internet Servers
  • Many computers are on the Internet
  • Yours called a client computer
  • Internet server computers computers that
    provide information and services on the Internet

14
Internet Servers
15
Internet Servers
Web server provides information and services to
Web surfers
16
Internet Servers
Mail server provides e-mail services and accounts
17
Internet Servers
FTP (file transfer protocol) server maintains
downloadable files
18
Internet Servers
IRC (Internet Relay Chat ) server supports
discussion groups and chat rooms
19
Data Transmission in Internet
  • When you transmit data, it is broken up into
    small pieces called packets
  • A packet is a parcel of data that is sent across
    a network
  • Has the address of its sender
  • Has the address of the destination
  • Has some data
  • When they reach the destination, they are put
    back together into original form
  • The computers must follow proper communication
    protocols to transmit packets

20
Communications Protocols
  • network protocols
  • machines rather than humans
  • all communication activity in Internet governed
    by protocols
  • human protocols
  • whats the time?
  • I have a question
  • introductions
  • specific msgs sent
  • specific actions taken when msgs received, or
    other events

protocols define format, order of msgs sent and
received among network entities, and actions
taken on msg transmission, receipt
21
Communications Protocols
  • TCP/IP (Transport Control Protocol/Internet
    Protocol??????/Internet??) primary protocol for
    transmitting information over the Internet
  • HTTP (Hypertext transfer protocol??????? )
    supports the movement of information over the Web
  • FTP (File transfer protocol,??????) the
    communications protocol you use to transfer
    information from one computer to another

22
Internet Address and Router
  • IP Address (IP??) An identifier for a computer
    or device on a TCP/IP network. The format of an
    IP address is a 32-bit numeric address written as
    four numbers separated by periods. Each number
    can be zero to 255. For example, 204.194.30.130
  • Router (???) Device which checks the IP address
    of the data at every intersection on the back
    bone, that carries the IP address of its
    destination .

23
Domain Name
  • People find it difficult to remember long strings
    of numbers, so host computers also have names
    called domain names
  • Domain name fully qualified domain name
    (FQDN), usually typed in all lowercase
  • Key component of URLs and e-mail addresses
  • www. msu.edu/biologycatalog.htm - www.msu.edu is
    the domain name

24
Domain Names ??
  • Typed in lowercase
  • Ends with three letter extension which is its
    top-level domain
  • Top-level domain

25
Domain Name Space ????
??????
??????
26
Domain Name System
  • Each name corresponds to an IP address
  • Domain name system Huge database that houses
    the names and IP addresses
  • Domain name servers Computers that house the
    database

27
Finding IP Address with nslookup
28
Applications of Internet
  • Bulletin Board System (BBS)
  • Conferences Online
  • IRC (Internet Relay Chat)
  • Internet telephony
  • Web
  • Email

29
Bulletin Board System (BBS)
  • Provides a messenger service.
  • Used as a repository for software and documents
    that may be copied.
  • Provides a place for people to converse.
  • This type system is quickly being replaced by the
    World Wide Web.
  • BBSs are still in existence.
  • bbs.scu.edu.cn

30
Conferences Online
  • Computer conference (electronic conference) An
    electronic meeting that can take place at the
    convenience of the participants.
  • Conference participants can type in questions or
    comments so that other members can see them and
    respond.
  • WELL (Whole Earth Lectronic Link)
  • Has thousands of users accessing more than 100
    public conferences (topics).
  • Usenet (Users Network)
  • Hundreds of conferences organized by topic.

31
IRC (Internet Relay Chat)
  • Developed in 1988 by Jarkko Oikarinen in Finland.
  • The original was a text-based Internet version.
  • Real-time online chat facilities chat rooms.
  • Communication is accomplished via typing text
    over a channel
  • Participants can occupy one of the many public
    chat rooms where everyone can read and respond,
    or go into private rooms or celebrity chat
    rooms.

32
Internet telephony
  • The term Internet telephony specifically refers
    to the provisioning of communications services
    over the public Internet, rather than via the
    public switched telephone network (PSTN). .
  • The successful case Skype, google talk

33
World Wide Web (WWW or the Web)
  • What is the Web ????
  • Billions of documents, called Web pages ??,
    available to anyone connected to the Internet

A Web site is a collection of related Web pages
You can share information by creating Web pages
or posting photos on a photo sharingcommunity
A podcast is recorded audio stored on a Web
sitethat can bedownloaded
A Web page contains text, graphics, audio,
video, and links to other Web pages
A blog consists of time-stamped articles ina
journal format
34
Difference between the Web and Internet
  • In the words of Tim Berners-Lee,
  • On the Net, you find computers on the Web, you
    find the documents, sounds, videos, and
    information
  • On the Net, the connections are cables between
    computers on the Web, connections are hypertext
    links
  • The internet is a communications systems and the
    web is an interlinked collection of information
    that flows over the Net

35
How does Web work?a very first sight
36
Elements of Web
  • Web Browser the programs to allow you view the
    web
  • Web Server the programs to deliver web content
    to browser
  • Web Page the web document file usually written
    in HTML or comparable markup language
  • HTTP (Hypertext Transfer Protocol) the protocol
    that allows Web browsers to communicate with Web
    servers

37
Web Page
  • A document file especially created for Web
    viewing
  • usually written in HTML or comparable markup
    language
  • The main distinction of web page is to provide
    hypertext
  • Hypertext will navigate to other web pages via
    links
  • Hypertext - Refers to any word or phrase in an
    electronic document, which can be used as a
    pointer to a related text passage.
  • Hypertext link - Any text or image that has been
    designated as a means of accessing related
    material.
  • Websites are composed of a series of Web pages.

38
  • In hypertext, one follows the links to related
    information.

Columbus sailed west under the auspices of
Queen Isabella of Spain. She commissioned...
Queen Isabellas husband was King Ferdinand...
A biography of King Ferdinand, he reigned from...
39
HTML
  • HTML (Hypertext Markup Language) is a set of
    specifications for creating documents
  • HTML document plain text, or ASCII, document
    with embedded HTML tags
  • HTML tags specify how the document should appear
    when displayed
  • World Wide Web Consortium (W3C) organization
    that reviews and revises HTML standard
  • HTML 3.2 in early 1997, 4.0 in late 1997, 4.01,
    in 1999

40
  • HTML tags, such as ltHRgt and ltBgt, are enclosed in
    documents
  • Treated as instructions to the browser
  • ltHRgt creates a horizontal rule
  • ltBgtCaterpillarslt/Bgt love sugar
  • ltBgt,lt/Bgt make the word Caterpillars bold
  • Is not case-sensitive (ltbgt is same thing as ltBgt)

41
(No Transcript)
42
  • Formatting tags change the appearance of text
  • Link tags specify where and how to display
    links
  • Media tags specify how to display media
    elements
  • Operational tags specify the basic setup for a
    Web page

43
(No Transcript)
44
  • Server may have other software, and, for
    efficiency, devotes one port for HTTP requests,
    one port for FTP, and one port for e-mail
  • Logical port created by communications software
    and used by client software to make a connection
    to a specific server
  • Port 80 HTTP
  • Port 25 SMTP e-mail
  • Port 21 FTP

45
HTTP
  • HTTP (Hypertext Transfer Protocol) works in
    conjunction with TCP/IP to get Web resources to
    your desktop
  • Has commands or methods that help your web
    browser communicate with server
  • Transports your request to server and back
  • HTTP status code indicates whether or not the
    browsers request could be fulfilled

46
Web browser
  • What is a Web browser ????

47
Web Browser
  • Request a web page from a web server by typing
    URL
  • Display the received web page to users
  • The server sends the data for the web page which
    contains the information to be viewed and a set
    of instructions that tells your browser how to
    display it.
  • Microsoft Internet Explorer
  • Netscape Navigator
  • Firefox

48
URL
  • The uniform resource locator (URL,???????) is the
    unique identifier of a web page.
  • The location window displays the URL of the
    current page.

49
More Detail about URL
  • URL is the address of a Web resource
  • http//www.icarnegie.com/courses.html might be
    interpreted this way Using hypertext transfer
    protocol(http), retrieve the file on
    www.icarnegie.com named /courses.html.

50
URLs
  • The format is
  • protocol//host.domainport number/path/filename
  • Protocol will be used to retrieve the
    information. Some of the options are
  • file find a file on your computer
  • http hypertext transfer protocol - find an html
    file on a WWW server
  • ftp file transfer protocol - find a file on the
    Internet
  • telnet connection to a telnet service (a
    terminal emulator)
  • mailto send a mail message, use SMTP

51
Absolute and relative URLs
  • Absolute URLs ??URL
  • Like a complete street address, e.g., 140-09,
    155th street, New York, USA
  • E.g., http//www.scu.edu/department/
  • Usually used to link pages between sites
  • Relative URLs ??URL
  • Like directions, e.g., down the street and turn
    left at the traffic lights
  • E.g., sc/resources.htm
  • Usually used to link pages within a site

52
Example
Current URL Target URL Relative URL
http//sw.scu.edu.cn/index.htm http//sw.scu.edu.cn/staff.htm staff.htm
http//sw.scu.edu.cn/index.htm http//sw.scu.edu.cn/bbs/topic1.htm bbs/topic1.htm
http//sw.scu.edu.cn/bbs/topic1.htm http//sw.scu.edu.cn/index.htm ../index.htm
53
Access Website with URL
54
Helper Applications, Plug-Ins, Players
  • The native file formats for early browsers
    typically were limited to documents in HTML
    format and graphics files in GIF and JPEG formats
  • Files that are not handled by the browser
    sometimes require you to download helper
    application, plug-in, or player in order to
    handle the files

55
  • Helper application program that extends a
    browsers ability to work with file formats
  • Updates your system so browser can automatically
    open helper application that works with a
    specific file format
  • Used by browser to open non-HTML file format

56
  • Plug-in type of helper application, pioneered
    by Netscape developers, that can be activated by
    the EMBED tag inserted in an HTML document
  • Player any helper application or plug-in that
    helps a browser display a particular file format

57
MIME Types
  • Multipurpose Internet Mail Extensions
  • ???Internet????
  • Designed for the interchange of data among
    various e-mail systems
  • Allows for universal interchange of data
  • They define how an attachment is to be read
  • With Web browsers, MIME types tell it what
    plug-ins to use
  • MIME type designations have two components a
    type and a subtype, which are separated by a
    slash (/).

58
Extended Web Architecture
The host-host data transfers usually involve one
MIME file
59
MIME Types
????????? .html,.htm text/html
???? .txt text/plain
RTF?? .rtf application/rtf
GIF?? .gif image/gif
JPEG?? .jpeg,.jpg image/jpeg
au???? .au audio/basic
MIDI???? mid,.midi audio/midi,audio/x-midi
RealAudio???? .ra, .ram audio/x-pn-realaudio
MPEG?? .mpg,.mpeg video/mpeg
AVI?? .avi video/x-msvideo
GZIP?? .gz application/x-gzip
TAR?? .tar application/x-tar
60
Example 1
  • Mime-Version 1.0 //???1.0 Content-Type
    multipart/mixed boundary"IMA.Boundary.750407228"
    //???????? --IMA.Boundary.750407228
    Content-Type text/plain charsetUS-ASCII
    //??????,???ASCII? Content-Transfer-Encoding
    7bit //????7? Content-Description ccMail note
    part

61
Example 2
  • lthtmlgt
  • ltheadgt
  • ltmeta HTTP-EQUIV"content-type"
  • CONTENT"text/html charsetUTF-8"gt
  • lttitlegtGoogle ??lt/titlegt
  • lt/headgt
  • ltbodygt
  • lt/bodygt
  • lt/htmlgt

62
Web Server
  • Either the hardware (the computer) or
    the software (the computer application)
  • Web server responds with the content of a
    specific resource that a web browser requests or
    an error message if unable to do so.
  • The requested resource is typically a real file
    on the server's storage.
  • Commonly used Web Server (software)
  • Apache Tomcat
  • IIS (Internet Information Server)

63
5.1.2 Internet Languages
  • HTML
  • XML
  • JavaScript
  • Java

64
Drawbacks limitations of HTML
  • HTML has a fixed tag set
  • HTML is a presentation technology and is flat
  • High traffic volume.
  • HTML supports methods for data presentation.
    Cant markup data in any meaningful way
  • Search engines return far to many hits
  • Cant specify collections of related pages

65
????????
  • ??????????????HTML(???????)???,??????Windows??????
    ?????????,????????????????????
  • ????????,????? FrontPage?DreamWeaver???

66
  • 1.FrontPage2002
  • FrontPage2002???????????????,?????????????????????
    ???????,?????????????????
  • 2.DreamWeaver MX
  • DreamWeaver MX ?Macromedia???????????????,????????
    ????????,??????HTML?????,???????????DreamWeaver
    MX??????????,???????????????????????,?????????????
    ???,???????????

67
  1. HTML ??

HTML ????????????? ?????????????????? ????,???HTM
L???????? ????(???),????????? ?? ??????????,?????
???????????,?????? ?????
68
???HTML ?????? lt???gt????lt/???gt ?????????lt
gt???? HTML ????????????? ???,?????????????? ?????
????????,???? ???lt?????????/?
69
2. HTML ??
HTML ????????????? ???????????HTML
?? ?????????,??Windows ??????Notebook,?????HTML
?? ???????????,?? FrontPage,DreamWeaver,??HTML
???
70
?????HTML ?????
ltHTMLgt ltHEADgtltTITLEgt??lt/TITLEgtlt/HEADgt ltBODYgt ltCENT
ERgt ltH1gt????????lt/H1gt ltHR size6 width"50"
noshadegt ltfont size"4"gt 1.MCSE????ltbrgt2.ATC
????ltbrgt3.Adobe????ltbrgtlt/fontgt lt/CENTERgt lt/BODYgt lt
/HTMLgt
71
???HTML??,?????????,????????????????????????????
,?HTML????????????,???????????,?ltHTMLgt\ltHEADgt?,???
????????,??????????????????
72
3. HTML ????
???? HTML ??,?????? (Header)???(Body)???(Title)??
??,??? ltHEADgt?ltBODYgt? ltTITLEgt ????????????HTML???
? ????????, ????? ltHTMLgt ???????
73
ltHTMLgt??ltHTMLgt?lt/HTMLgt?? ?????????????,???? ??HT
ML ????????????? ???????
ltHEADgt??ltHEADgt?lt/HEADgt?? ????????,????????? ???,
?????????????? ?????????????????? (Client area)??
74
ltBODYgt??ltBODYgt?lt/BODYgt?? ?????????,???????? ??,?
?????????????? ???(Client area)????
ltTITLEgt??ltTITLEgt?????? ?????,??????????? ltTITLEgt
???????????????
75
ltHngt?lt/Hngt????????,?????????????,??????????
????HTML???6???????,????ltHngt?????lt/Hngt???n??16??
???(1???,6???)? ltFONT sizengt?lt/FONTgt?????
?????????????????, size????????,n????17,????3?
76
ltHR sizen widthnn noshadegt??????????
?size????????,n?????2(??)?Width???????????,???????
?????,????100?noshade???????????????,????????????
??? ltCENTERgt?ltBRgt??ltCENTERgt???????????????ltB
Rgt????????
77
4. HTML ???
?HTML ???anchor ??ltagt?? ???,????????????? ?HTML
?????????????? ??HTML ????????????? ????????????hr
ef ??? ????lt/agt,????
lta hrefURLgthere's a link to another page.lt/agt
78
??????,ltagtlt/agt????? ??,heres a link to another
Page ???????href?????URL,URL ????Web?Internet????
,?? ?????????URL???????? ??????? ??????,????????
????,????????????? ?????HTML?,????????, ???????,??
???????
79
????
??????,??????????,????URL???URL???????
??URL??????,??????????????????????????,URL????????
?,???????????????,???????URL??????URL???? http//
www.sina.com.cn/index.htm
80
??URL????????????,???????,???????URL???????????
????????????????,??????????????????????????????,??
??????????????????URL??????????(??????URL)????????
????(?????URL)?
81
????
??????,?????????????,??????????HTML???????,???
???????book,??????????????????????URL???URL??????.

82
??????URL?anchor???????,????????????????? ???????
?ltH2gtProposalslt/H2gt. ???anchor???????ltH2gtltAgtProp
osalslt/Agtlt/H2gt? ??,??NAME?? ltH2gtltA
NAME"pro"gtProposallt/Agtlt/H2gt? ??????????,?????????
,???????????????????? ?????URL?,??Proposals??index
jc.htm???,??????ez-online.hb.cninfo.net????swzn???
?,?HTML???? ltA HREF" http//ez-nline.hb.cninfo.n
et/swzn/indexjc.htm pro"gtProposallt/Agt
83
5. ????
  • ??????
  • ???????????,?????????????????????????????GIF
    ?JPEG?
  • ???????HTML ?????
  • ?,???GIF ??,????GIF ?
  • ?????????????????
  • ??????,?????JPEG ??
  • ????

84
  • ????
  • HTML???,IMG ????????
  • ??SRC ???????????
  • ????,ltimg srcURLgt?
  • ??ALT ???????????
  • ?,?????????,???HTML
  • ???????ALT ?????????
  • ??????????????,???
  • ??????????????????
  • ?????????,????????
  • ????

85
  • ???????
  • (1). ?????????
  • ???????IMG ???ALIGN ?
  • ????,?????????????
  • ????(Baseline)?????????
  • ???????

????????
????????????? ALIGNup
????????????? ALIGNmiddle
????????????? ALIGNbottom(???)
??????????????? ALIGNtexttop
?????????????? ALIGNbaseline
86
(2). ???? ???????????????? ??,??????????,??? ALIG
Nleft?ALIGNright? ?ALIGN?right?,???????? ?,????
???????ALIGN?? left?,??????,???????? ??????,?????
????
87
(3). ?????? ???? ?????????? ?WIDTH?????? ????
?????????? ?HEIGHT?????? ?????????????? 10090??
????????? 200180????,??WIDTH?HEIGHT ?????????200?
180,????
ltIMG SRCwww.gif WIDTH200 HEIGHT180gt
88
6. ??
???HTML?????TABLE??? ??,???????ltTABLEgt,?? lt/TABLE
gt?????????????
89
  • ??????
  • ????????,??????
  • (TH????????????)???
  • (TD???????),???????
  • ???????????ltCAPTIONgt?
  • ?,??lt/CAPTIONgt????????
  • ?????????????????
  • ????ltTRgt??????????

90
??
lttable bordergtltcaptiongtInternet??????lt/captiongt ltt
rgtltthgt????\??lt/thgtltthgt1993?lt/thgtltthgt1994?lt/thgtltth
gt1995?lt/thgtlt/trgt lttrgtltthgt?????ltbrgt(Giga
Byte)lt/thgtlttdgt5,159lt/tdgtlttdgt10,294lt/tdgtlttdgt19,119
lt/tdgtlt/trgt lttrgtltthgtFTPlt/thgtlttdgt2,412lt/tdgtlttdgt4,243
lt/tdgtlttdgt5,784lt/tdgtlt/trgt lttrgtltthgtWWWlt/thgtlttdgt0.122
lt/tdgtlttdgt269lt/tdgtlttdgt3,382lttdgtlt/trgt lt/tablegt
91
XML
  • XML is a text document markup language whose full
    name is eXtensible Markup Language(???????).
  • XML tags is used to describe what a piece of text
    means.
  • The XML tags differ from HTML tags mainly in two
    functions
  • XML tags is to describe what a piece of text
    means such as ltphonegt 123lt/phonegt while HTML tags
    primarily concern with how text should be
    displayed.
  • XML has no predefined tags while HTML does.

92
An example XML document
  • XML documents use a self-describing and simple
    syntax.

lt?xml version"1.0" encoding"ISO-8859-1"?gt
ltnotegt lttogtTovelt/togt ltfromgtJanilt/fromgt
ltheadinggtReminderlt/headinggt ltbodygtDon't forget
me this weekend!lt/bodygt lt/notegt
93
An example XML document
  • XML documents use a self-describing and simple
    syntax.

lt?xml version"1.0" encoding"ISO-8859-1"?gt
ltnotegt lttogtTovelt/togt ltfromgtJanilt/fromgt
ltheadinggtReminderlt/headinggt ltbodygtDon't forget
me this weekend!lt/bodygt lt/notegt
XML declaration - defines the XML version and
the character encoding used in the document. In
this case the document conforms to the 1.0
specification of XML and uses the ISO-8859-1
(Latin-1/West European) character set.
94
An example XML document
  • XML documents use a self-describing and simple
    syntax.

lt?xml version"1.0" encoding"ISO-8859-1"?gt
ltnotegt lttogtTovelt/togt ltfromgtJanilt/fromgt
ltheadinggtReminderlt/headinggt ltbodygtDon't forget
me this weekend!lt/bodygt lt/notegt
Root element is mandatory.
95
An example XML document
  • XML documents use a self-describing and simple
    syntax.

The next 4 lines describe 4 child elements of the
root (to, from,heading, and body)
lt?xml version"1.0" encoding"ISO-8859-1"?gt
ltnotegt lttogtTovelt/togt ltfromgtJanilt/fromgt
ltheadinggtReminderlt/headinggt ltbodygtDon't forget
me this weekend!lt/bodygt lt/notegt
96
An example XML document
  • XML documents use a self-describing and simple
    syntax.

lt?xml version"1.0" encoding"ISO-8859-1"?gt
ltnotegt lttogtTovelt/togt ltfromgtJanilt/fromgt
ltheadinggtReminderlt/headinggt ltbodygtDon't forget
me this weekend!lt/bodygt lt/notegt
Finally the last line defines the end of the root
element.
97
XML Syntax (1) ??
  • All XML elements must have a closing tag
  • In HTML some elements do not have to have a
    closing tag. The following code is legal in HTML
  • ltpgtThis is a paragraph ltpgtThis is another
    paragraph
  • In XML all elements must have a closing tag, like
    this
  • ltpgtThis is a paragraphlt/pgt ltpgtThis is another
    paragraphlt/pgt 
  • Note You might have noticed from the previous
    example that the XML declaration did not have a
    closing tag. This is not an error. The
    declaration is not a part of the XML document
    itself. It is not an XML element, and it should
    not have a closing tag.

98
XML Syntax (2)
  • XML tags are case sensitive
  • Unlike HTML, XML tags are case sensitive.
  • With XML, the tag ltLettergt is different from the
    tag ltlettergt.
  • Opening and closing tags must therefore be
    written with the same case
  • ltMessagegtThis is incorrectlt/messagegt
  • ltmessagegtThis is correctlt/messagegt

99
XML Syntax (3)
  • All 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
  • ltbgtltigtThis text is bold and italiclt/bgtlt/igt
  • In XML all elements must be properly nested
    within each other like this
  • ltbgtltigtThis text is bold and italiclt/igtlt/bgt

100
XML Syntax (4)
  • All 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
  • ltrootgt ltchildgt ltsubchildgt.....lt/subchildgt
    lt/childgt lt/rootgt

101
XML Syntax (5)
  • Attribute values must always be quoted
  • With XML, it is illegal to omit quotation marks
    around attribute values. 

lt?xml version"1.0" encoding"ISO-8859-1"?gt
ltnote date12/11/2002gt lttogtTovelt/togt ltfromgtJanilt
/fromgt lt/notegt
lt?xml version"1.0" encoding"ISO-8859-1"?gt
ltnote date"12/11/2002"gt lttogtTovelt/togt
ltfromgtJanilt/fromgt lt/notegt
102
XML Syntax (6)
  • 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,

103
XML Syntax (7)
  • Comments in XML
  • The syntax for writing comments in XML is similar
    to that of HTML.
  • lt!-- This is a comment --gt

104
XML Validation
  • XML with correct syntax is Well Formed XML.
  • XML validated against a DTD is Valid XML.
  • A "Valid" XML document is a "Well Formed" XML
    document, which also conforms to the rules of a
    Document Type Definition (DTD)

lt?xml version"1.0" encoding"ISO-8859-1"?gt
ltnotegt lttogtTovelt/togt ltfromgtJanilt/fromgt
ltheadinggtReminderlt/headinggt ltbodygtDon't forget
me this weekend!lt/bodygt lt/notegt
105
Definition of DTD
  • DTD(Document Type Definition?????? )
  • 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.

106
DTD Example
lt?xml version"1.0"?gt lt!DOCTYPE note SYSTEM
"note.dtd"gt ltnotegt lttogtTovelt/togt
ltfromgtJanilt/fromgt ltheadinggtReminderlt/headinggt
ltbodygtDon't forget me this weekend!lt/bodygt
lt/notegt
lt!ELEMENT note (to,from,heading,body)gt lt!ELEMENT
to (PCDATA)gt lt!ELEMENT from (PCDATA)gt
lt!ELEMENT heading (PCDATA)gt lt!ELEMENT body
(PCDATA)gt
note.dtd
107
JavaScript
  • lthtmlgtltheadgtlttitlegtJavaScript Demonstrationlt/title
    gt
  • ltscript type"text/javascript" language"JavaScrip
    t1.2"gtfunction display()
    document.body.bgColor "black" var ln1
    "Hello World!" var ln2 "This is the "
    document.title " page." var str
    ln1.fontcolor("lime") "ltbr /gt"
    ln2.fontcolor("red")  document.writeln(str)
  • lt/scriptgt
  • lt/headgt
  • ltbodygtltscript type"text/javascript"
    language"JavaScript1.2"gt      display()
  •  lt/scriptgt
  • lt/bodygtlt/htmlgt

108
JavaScript example
  • lthtmlgt
  • ltheadgt My first JavaScript! lt/headgt
  • ltbodygt
  • ltbrgt This is a normal HTML document.
  • ltbrgt
  • ltscript language"LiveScript"gt
    document.write("??? JavaScript ???!")
  • lt/scriptgt
  • ltbrgt Back in HTML again.
  • lt/bodygt
  • lt/htmlgt

109
Java Applet
import java.applet.Appletimport
java.awt.Graphicspublic class Demonstration
extends Applet   public void paint(Graphics g)
    g.drawRoundRect(5, 5, 100, 50, 10,
10)    g.drawString("Hello World!", 23,
35)  
ltpgtHere is the result of the applet ltapplet
code"Demonstration.class" width"110
height"60" align"middle"gtlt/appletgtlt/pgt
110
End of Unit5.1
Write a Comment
User Comments (0)
About PowerShow.com