XML - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

XML

Description:

TVGuide channel ... /channel time ... /time title ... /title ... TVGuide Design Tips. Think logically and design accordingly. Ex. ... – PowerPoint PPT presentation

Number of Views:144
Avg rating:3.0/5.0
Slides: 21
Provided by: DE81
Category:
Tags: xml | tvguide

less

Transcript and Presenter's Notes

Title: XML


1
XML
  • CS 105

2
What is XML?
  • XML stands for Extensible Markup Language.
  • XML is a markup language like HTML.
  • XML was designed to describe data.
  • You must define your own tags.

3
An XML Example
  • ltnotegt
  • lttogtJohnlt/togt
  • ltfromgtMerrylt/fromgt
  • ltheadinggtReminderlt/headinggt
  • ltbodygtDont forget to pick up the boxlt/bodygt
  • lt/notegt

4
Why XML?
  • There is a huge number of websites on the web and
    each website posts tunes of web pages. Also the
    number of web sites increases day by day.
  • It is getting harder to find the information we
    are looking for.

5
Why XML?
  • We need search engines to locate the information
    that we are looking for.
  • Most of the WWW documents are in HTML.
  • Search engines can bring you tons of pages.
  • Note that we humans are smart. Most of the times
    we can realize the content of a webpage by
    reading it. But computer programs are not and
    search engine is a computer program.

6
XML is the solution.
  • HTML describes how to display a page.
  • But it does nothing to describe the contents of a
    page.
  • We need a language to convey the content of a web
    page.
  • XML is the solution.

7
XML
  • XML indicates
  • What information is contained within a webpage.
  • Where that information is on the page.

8
XML and HTML
  • XML is not a replacement for HTML
  • XML was designed to describe data in a format
    that you want and to focus on what data is.
  • HTML was designed to display data in a format
    that you prefer.
  • HTML is about displaying information, while XML
    is about describing information

9
XML and HTML
  • XML and HTML complement each other.
  • XML describes the data.
  • HTML displays the data.

10
eXtensible Markup Language
  • eXtensible
  • Markup
  • Language
  • XML is supported by many platforms and many
    tools.
  • A lot of web applications are using XML now.

11
XML vs. HTML
  • ltHTMLgt
  • ltBODYgt
  • ltULgt
  • ltLIgt 1 kg apple
  • ltLIgt 1/2 Sugar
  • ltLIgt 1 kg white flour
  • ltLIgt 250 g butter
  • lt/ULgt
  • ltPgt Place apples in a bowl.
  • Toss with flour until covered. then, ...
  • lt/BODYgt
  • lt/HTMLgt
  • ltRECIPEgt
  • ltINGREDIENTSgt
  • ltINGREDIENTgt 1Kg apple lt/INGREDIENTgt
  • ltINGREDIENTgt 1/2Kg Sugar lt/INGREDIENTgt
  • ltINGREDIENTgt 1 kg white flour
    lt/INGREDIENTgt
  • ltINGREDIENTgt 250 g butter lt/INGREDIENTgt
  • lt/INGREDIENTSgt
  • ltINSTRUCTIONSgt
  • ltINSTRUCTIONgt Place apples in a bowl.
  • lt/INSTRUCTIONgt
  • ltINSTRUCTIONgt Toss with flour until
    covered.
  • lt/INSTRUCTIONgt
  • .
  • lt/INSTRUCTIONSgt
  • lt/RECIPEgt

12
XML
  • Labels the data
  • Structures the data
  • Example

13
Rules for Well-Formatted XML
  • Every XML document must have a special tag lt?xml
    version1.0?gt to tell web browser it is an xml
    file
  • Every XML document must have a single,
    all-enclosing root tag
  • Every XML element must have a corresponding
    closing tag
  • Just as HTML, XML elements must be properly
    nested
  • XML tags are case sensitive, ltFOODgt and ltfoodgt
    are different
  • The value of an attribute must appear in
    quotation marks (either double or single
    quotation marks work)

14
XML Element Names
  • Names can contain letters, numbers and other
    characters
  • Names cannot begin with a number or an underscore
  • Names cannot begin with the prefix XML or xml
    or xML etc.
  • Names cannot contain spaces

15
Good, Bad, and Unparsable
  • Common errors in XML misspelling tag names, have
    more than one root-level element, forgetting to
    close an open quote
  • If XML file is well-formed, the browser will
    display the file in a hierarchical fashion,
    otherwise, cannot load the file
  • The XML file could be designed poorly although it
    is well-formed.

16
Good, Bad and Unparsable
  • Bad example
  • ltTVGuidegt
  • ltchannelgtlt/channelgt
  • lttimegtlt/timegt
  • lttitlegtlt/titlegt
  • ltdescriptiongtlt/descriptiongt
  • ltchannelgtlt/channelgt
  • lttimegtlt/timegt
  • lttitlegtlt/titlegt
  • ltdescriptiongtlt/descriptiongt
  • lt/TVGuidegt

17
Good, Bad and Unparsable
  • Solution
  • ltTVGuidegt
  • ltprogramgt
  • ltchannelgtlt/channelgt
  • lttimegtlt/timegt
  • lttitlegtlt/titlegt
  • ltdescriptiongtlt/descriptiongt
  • lt/programgt
  • ltprogramgt
  • ltchannelgtlt/channelgt
  • lttimegtlt/timegt
  • lttitlegtlt/titlegt
  • ltdescriptiongtlt/descriptiongt
  • lt/programgt
  • lt/TVGuidegt

18
Design Tips
  • Think logically and design accordingly
  • Ex. Use ltCDgtlt/CDgt for cd collections
  • If you want it, tag it
  • Ex. Dont use ltTimegt1000pm
  • ltnamegt..lt/namegt
  • lt/Timegt
  • Use ltTimegt ltslotgt1000pmlt/slotgt
  • ltnamegtlt/namegt
  • lt/Timegt
  • Think generically
  • Ex. Dont use ltNBCgtlt/NBCgt ltABCgtlt/ABCgt to group
    different networks
  • Use ltnamegtNBClt/namegtltnamegtABClt/namegt
  • Think hierarchically
  • Start with a meaningful root element and work
    downward to successive levels of detail

19
What is XSL?
  • XSL is a language that allows one to describe for
    a browser how to process an XML file.
  • XSL can convert an XML file into another format
    XML file.
  • XSL can convert an XML file into a non-XML file.

20
XSL
  • The most common type of XSL processing is to
    convert XML file into HTML file which can be
    displayed by browsers. We will focus on this use
    of XSL.
  • XSL is the bridge between XML and HTML.
  • We can use XSL to have different HTML formats of
    the same data represented in XML.
  • Separating data (contents) from style tags
    (display commands).
  • Example
Write a Comment
User Comments (0)
About PowerShow.com