CIS 275 - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

CIS 275

Description:

CIS 275 Web App Dev I. XML. 2. Introduction to XML. XML stands for ... If you have Netscape 6 or IE 5 or higher you can view the XML file and the XSL style sheet. ... – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 18
Provided by: raj11
Category:
Tags: cis | download | netscape

less

Transcript and Presenter's Notes

Title: CIS 275


1
CIS 275Web App Dev I
  • XML

2
Introduction to XML
  • XML stands for ________________________.
  • HTML was designed to display data.
  • XML was designed to _________ data.
  • With XML, you define your own _______.
  • Sample XML document
  • 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

eXtensible Markup Language
describe
tags
3
How can XML be Used?
  • With XML, data can be stored separately from the
    ______ code.
  • With XML, data are stored in plain _____ format.
  • With XML, data can be exchanged between
    ____________ systems.
  • Important languages like _____ are written in
    XML.
  • XML is important for _____ applications.

HTML
text
incompatible
WML
B2B
4
XML Document Structure
  • Sample XML document
  • 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
  • The XML document above consists of
  • an XML ___________
  • One ______ element
  • Four _______ elements

declaration
root
child
5
XML Syntax
closing
  • All XML elements must have a _________ tag.
  • XML tags are ______ sensitive.
  • XML elements must be properly nested.
  • ltbgtltigtThis text is bold and italiclt/igtlt/bgt
  • All XML documents must have a ______ element.
  • Attribute values must be _________.
  • ltnote date"12/11/2002"gt
  • Comments in XML look like this
  • lt!-- This is a comment --gt

case
root
quoted
6
XML Elements
  • XML documents are _________. New elements can be
    added without crashing an existing application.
  • XML elements have ____________ (there are parent,
    child, and sibling elements).
  • Elements have content
  • Some have only element content (e.g., the root
    element)
  • Some have simple (_____) content
  • lttitlegtMy First XMLlt/titlegt
  • Some have mixed content (element and simple)
  • Some have no content
  • ltprod id"33-657" media"paper"gtlt/prodgt
  • Elements may have ___________

extensible
relationships
text
attributes
7
Element Content
  • In this example, ltbookgt has _________ content,
    because it contains other elements.
  • ltchaptergt has _______ content because it contains
    both text and other elements.
  • ltparagt has ________ content (or text content)
    because it contains only text.
  • ltprodgt has _______ content, because it carries no
    information.
  • lt?xml version"1.0" encoding"ISO-8859-1"?gt
  • ltbookgt
  • lttitlegtMy First XMLlt/titlegt
  • ltprod id"33-657" media"paper"gtlt/prodgt
  • ltchaptergtIntroduction to XML
  • ltparagtWhat is HTMLlt/paragt
  • ltparagtWhat is XMLlt/paragt
  • lt/chaptergt
  • ltchaptergtXML Syntax
  • ltparagtElements must have a closing taglt/paragt
  • ltparagtElements must be properly nestedlt/paragt
  • lt/chaptergt
  • lt/bookgt

element
mixed
simple
empty
8
XML Attributes
  • Element attributes are not part of the data, but
    contain information about the data.
  • ltfile type"gif"gtcomputer.giflt/filegt
  • You should try to avoid using attributes,
    especially if the information feels like basic
    data.
  • One good use of attributes is for _____________.
  • ltmessagesgt
  • ltnote id"p501"gt
  • lttogtTovelt/togt
  • ltfromgtJanilt/fromgt
  • ltheadinggtReminderlt/headinggt
  • ltbodygtDon't forget me this weekend!lt/bodygt
  • lt/notegt

identification
9
XML Validation
syntax
  • A well formed XML document has correct _______.
  • A valid XML document is both well formed and
    conforms to a DTD (__________ Type Definition).
  • lt?xml version"1.0" encoding"ISO-8859-1"?gt
    lt!DOCTYPE note SYSTEM "InternalNote.dtd"gt
  • A DTD defines document structure and legal
    ______.
  • An XML _________ is the W3C alternative to DTD.
  • Invalid XML documents will not execute properly.
  • See http//www.w3.org/XML/Schema.html for
    details.
  • XML validators
  • http//www.w3schools.com/dom/dom_validate.asp

Document
elements
Schema
10
Internal DOCTYPE Declaration
  • lt?xml version"1.0" encoding"ISO-8859-1"?gt
  • lt!DOCTYPE note
  • 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
  • gt
  • ltnotegt
  • lttogtTovelt/togt
  • ltfromgtJanilt/fromgt
  • ltheadinggtReminderlt/headinggt
  • ltbodygtDon't forget me this weekendlt/bodygt
  • lt/notegt
  • PCDATA means _______ character data.

parsed
11
External DOCTYPE Declaration
  • XML (note.xml)
  • 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 weekendlt/bodygt
  • lt/notegt
  • DTD (note.dtd)
  • 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

12
Why use a DTD?
  • With DTD, your XML files can carry a description
    of its own _________ with it.
  • With a DTD, independent groups of people can
    agree to use a common DTD for ___________ data.
  • Your application can use a _________ DTD to
    verify that the data you receive from the outside
    world is valid.
  • You can also use a DTD to _______ your own data.

format
interchanging
standard
verify
13
Viewing XML Files
  • An XML document can be viewed in IE 5.0 by
    typing the URL or double-clicking the icon.
  • Look at this XML file note.xml.
  • Invalid XML files will not display
    note_error.xml.
  • Other Examples
  • An XML CD catalog
  • An XML plant catalog
  • A Simple Food Menu

14
Displaying XML with CSS
  • You can view an XML with the help of a CSS, but
    this is not the future of XML.
  • Take a look at this pure XML file The CD Catalog
  • Then look at this style sheet The CSS file
  • Finally, view the CD Catalog formatted with the
    CSS file
  • You can write a web page using XML, but this is
    not recommended A homepage written in XML.
  • ______ (HTML defined as XML) is recommended for
    creating web pages.

XHTML
15
Displaying XML with XSL
  • XSL (__________ Style Language) is the preferred
    style sheet language of XML.
  • XSL is far more sophisticated than CSS.
  • If you have Netscape 6 or IE 5 or higher you can
    view the XML file and the XSL style sheet.
  • View the result in IE 6
  • View the result in IE 5

eXtensible
16
XML Embedded in HTML
  • The unofficial ______ tag is used to embed XML
    data within HTML.
  • ltxml id"note"gt
  • ltnotegt
  • lttogtTovelt/togt
  • ltfromgtJanilt/fromgt
  • ltheadinggtReminderlt/headinggt
  • ltbodygtDon't forget me this weekend!lt/bodygt
  • lt/notegt
  • lt/xmlgt
  • You can embed a separate XML file.
  • ltxml id"note" src"note.xml"gt lt/xmlgt

ltxmlgt
17
Data Binding
  • Example of binding a data island to an HTML
    element (in the following case, _______)
  • lthtmlgt
  • ltbodygt
  • ltxml id"cdcat" src"cd_catalog.xml"gtlt/xmlgt
  • lttable border"1" datasrc"cdcat"gt
  • lttrgt
  • lttdgtltspan datafld"ARTIST"gtlt/spangtlt/tdgt
  • lttdgtltspan datafld"TITLE"gtlt/spangtlt/tdgt
  • lt/trgt
  • lt/tablegt
  • lt/bodygt
  • lt/htmlgt
  • Here is the result.
  • Here is the external XML file.

lttablegt
Write a Comment
User Comments (0)
About PowerShow.com