Web Technologies 20072008 - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

Web Technologies 20072008

Description:

TRACK Blue in Green (5:37) /TRACK /CD Document body ... Download the student resources of the Patrick Carey's book: 'New Perspectives on XML' ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 26
Provided by: dur9
Category:
Tags: technologies | web

less

Transcript and Presenter's Notes

Title: Web Technologies 20072008


1
Web Technologies2007/2008
  • Lecture 3b
  • XML

New Perspectives on XML, Patrick Carey Ioannis
Ivrissimtzis 14-Mar-2008
2
Overview
  • Introduction to XML
  • XML documents
  • CSS for XML

3
XML
  • XML stands for Extensible Markup Language.
  • XML conforms with the standards of the Standard
    Generalized Markup
  • Language (SGML).
  • An XML document structures information using
    tags. Unlike HTML,
  • XML is not restricted into predefined set of
    tags.
  • Parsers interpreting XML code and associated
    style sheets are built in
  • the main browsers IE and Mozilla.

4
Example
  • Example Consider the web-site of an online
    bookstore. We would like
  • to create records of books, storing the following
    information
  • Title
  • Author
  • Publisher
  • Price
  • Content Type (Fiction, Nonfiction)
  • Format (Paperback, Hardback)
  • ISBN

5
Example
  • The following code shows a possible XML code for
    one book
  • ltbookgt
  • lttitlegtNight Falllt/titlegt
  • ltauthorgtDemille, Nelsonlt/authorgt
  • ltpublishergtWarnerlt/publishergt
  • ltpricegt26.95lt/pricegt
  • ltcontentTypegtFictionlt/contentTypegt
  • ltformatgtHardbacklt/formatgt
  • ltisbngt0446576638lt/isbngt
  • lt/bookgt

6
PCDATA and CDATA
  • The previous piece of code is a sample of parsed
    character
  • data, (PCDATA).
  • PCDATA consists of all those characters that XML
    treats as parts of the
  • code of XML document
  • The XML declaration
  • The opening and closing tags of an element
  • Empty element tags
  • Character or entity references
  • Comments

7
PCDATA and CDATA
  • A CDATA section is a block of text the XML
    processor will interpret only
  • as text. The syntax is
  • lt! CDATA
  • Text block
  • gt

8
Overview
  • Introduction to XML
  • XML documents
  • CSS for XML

9
XML documents
  • An XML documents consist of three parts
  • The prolog
  • The document body
  • The epilog
  • The prolog provides information about the
    document.
  • The documents body contains the documents
    content structured as a tree.
  • The epilog contains any final comments or
    processing instructions.

10
Prolog
  • The first line of the prolog is the XML
    declaration, which tells the
  • processor that what follows is written using XML.
  • The syntax is
  • lt?xml versionversion number
    encodingencoding type standaloneyes no ?gt
  • A typical declaration would look like
  • lt?xml version1.0 encodingUTF-8
    standaloneyes ?gt

11
Document body
  • The basic blocks of an XML document are the
    elements (tags).
  • The syntax of an element is
  • ltelement_namegtContentlt/element_namegt
  • Example The XML file of a Jazz CD catalogue
    might contain an
  • element
  • ltArtistgtMiles Davislt/Artistgt

12
Document body
  • Elements can be nested
  • ltCDgtKind of Blue
  • ltTRACKgtSo What ((22)lt/TRACKgt
  • ltTRACKgtBlue in Green (537)lt/TRACKgt
  • lt/CDgt

13
Document body
  • The elements (and the element types) of an XML
    document create a
  • tree structure.
  • Example The element types used for the CD
    catalogue can have the
  • structure

SPECIALS
TITLE
MESSAGE
CD
PRICEUK
PRICEUS
ARTIST
TRACK
14
Document body
  • Example (cont.)
  • SPECIALS is the root of the tree. It groups
    everything together.
  • TITLE contains the title of the catalogue.
  • MESSAGE contains some text information about the
    catalogue.
  • CD contains information about a CD.
  • ARTIST contains the artists name.
  • PRICEUS contains the price of the CD in US.
  • PRICEUK contains the price of the CD in UK.
  • TRACK contains information about a track of the
    CD.

15
Document body
  • If an .xml document has no
  • style information, the browser
  • will show the tree structure of
  • the text.
  • That means that the browser
  • is aware of the structure
  • implied by the tags.

16
Document body
  • If a tree can not be constructed by the browser,
    an error message will
  • appear.
  • Exercise Remove a closing tag from a valid XML
    document and open
  • the file with a browser.

17
Document body
  • The document body may also contains CDATA

18
Document body
  • The document body may also contain references to
    special characters,
  • such as the symbol

19
Overview
  • Introduction to XML
  • XML documents
  • CSS for XML

20
CSS for XML
  • To create a style sheet, use the following
    syntax
  • selector attribute1value1 attribute2value2
  • Selector is an element (or set of elements) from
    the XML document.
  • Attribute and value are the style attributes and
    attribute values to be
  • applied.
  • Example
  • ARTIST colorred font-weightbold
  • will display the text of the ARTIST element in a
    red boldface type.

21
CSS file
  • Example The cascading style sheet JW.css

22
CSS for XML
  • The style sheet should be linked to the XML
    document. The syntax is
  • lt?xml-stylesheet typestyle hrefsheet ?gt
  • Style is the type of style sheet to access, and
    sheet is the name and
  • location of the style sheet.

23
Linking CSS to XML
  • Example Link the XML document to a style sheet

24
Formatted XML file
  • The formatted XML file would look like

25
Resources
  • Download the student resources of the Patrick
    Careys book
  • New Perspectives on XML
  • http//www.course.com/studentcenter/downloads.cfm?
    isbn9780619101886CFID1593130CFTOKEN97788713
Write a Comment
User Comments (0)
About PowerShow.com