XML - PowerPoint PPT Presentation

About This Presentation
Title:

XML

Description:

ADDRESS ::= STREET CITY STATE. PHONE, FIRST, LAST, STREET, CITY, STATE ::= STRING. addresses.dtd ... address (street, city, state) !ELEMENT street (#PCDATA) ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 26
Provided by: Pea36
Learn more at: http://www.cs.sjsu.edu
Category:
Tags: xml | addresses | street

less

Transcript and Presenter's Notes

Title: XML


1
XML
  • by Jon Pearce

2
What is XML?
XML eXstensible Markup Language a meta
language for defining markup languages.
Examples MathML, SVG (Scalable Vector
Graphics), WML (Wireless Markup Language), XBRL
(Extensible Business Reporting Language), XUL
(Extensible User Interface Language), PDML
(Product Data Markul Language), CML (Chemical
ML), VoiceXML, VML (Vector ML), cXML (Commerce
XML), tpaML (Traqding partner agreement XML),
SMBXML (Small to Medium Business XML), FinXML
(Financial XML), SOAP, XHTML, OWL
3
XML History
  • Standard Generalized Markup Language
  • Invented in 1980s for publishing industry
  • Markup meta language
  • HTML is an SGML language
  • Ancestor of XML

4
Uses of XML
  • Data Storage
  • Object Serialization
  • Presentation Independent
  • Language Independent
  • Application Initialization
  • Message Passing
  • Between Tiers
  • Data-Business-Presentation-Client
  • SOAP and Web Services

5
An XML Document Contains
  • A Prolog
  • Elements
  • lttaggt content lt/taggt
  • Comments
  • lt!-- don't read this --gt
  • CDATA Sections
  • lt!CDATA pre-formatted textgt
  • Processing Instructions (PIs)
  • lt? do it ?gt

6
Format of an XML Document
lt?xml version"1.0"?gtltrootgt ELEMENT
ELEMENT ...lt/rootgt
7
Tree Structure of an XML Document
8
A Document Prolog Contains
  • XML Declaration
  • lt?xml version"1.0" ?gt
  • DTD (optional)
  • Style Sheet (optional)
  • etc.

lt?xml version"1.0"?gtlt!DOCTYPE addresses SYSTEM
"addresses.dtd"gtlt?xml-stylesheet type"text/xsl"
href"addresses1.xsl"?gt
9
An XML Element Contains
  • ltTAG attributesgt content lt/TAGgt
  • ltDATE status"cancelled"gt
    09/01/2002lt/DATEgt
  • An empty element
  • ltTAG attributes /gt

10
Example book.xml
lt?xml version"1.0"?gtltaddressesgt PERSON
PERSON PERSON ...lt/addressesgt
11
A Person Element (1)
ltpersongt NAME ADDRESS PHONElt/persongt
12
A Person Element (2)
ltpersongt ltnamegt ltfirstgt Joe lt/firstgt
ltlastgt Smith lt/lastgt lt/namegt ltaddressgt
ltstreetgt 123 Sesame St lt/streetgt
ltcitygt New York lt/citygt ltstategt NY
lt/stategt lt/addressgt ltphonegt (555) 555-1234
lt/phonegt lt/persongt
13
Displaying XML in IE
14
Grammars
  • G a grammar
  • L(G) Language defined by G
  • w ?L(G) means w is a valid L(G) sentence
  • Example
  • G English grammar
  • G Java grammar

15
Grammar Rules
  • An EBNF grammar is a list of rules of the form
  • PARENT CHILDREN
  • CHILDREN is a regular expression
  • A B, A B, A, A?, 'leaf'

16
Addresses EBNF
ADDRESSES PERSONPERSON NAME ADDRESS
PHONENAME FIRST LASTADDRESS STREET CITY
STATEPHONE, FIRST, LAST, STREET, CITY, STATE
STRING
17
addresses.dtd
lt!ELEMENT addresses (person)gtlt!ELEMENT person
(name, address, phone)gtlt!ELEMENT name
(first, last)gtlt!ELEMENT first
(PCDATA)gtlt!ELEMENT last
(PCDATA)gtlt!ELEMENT address (street, city,
state)gtlt!ELEMENT street (PCDATA)gtlt!ELEMEN
T city (PCDATA)gtlt!ELEMENT state
(PCDATA)gtlt!ELEMENT phone (PCDATA)gt
18
book.xml (with a dtd)
lt?xml version"1.0"?gtlt!DOCTYPE addresses SYSTEM
"addresses.dtd"gtltaddressesgt PERSON PERSON
PERSON ...lt/addressesgt
19
Well Formed vs. Valid Documents
  • Validating Parsers determine if an XML document
    conforms to its DTD
  • Non-validating parsers merely determine if an xml
    document is well formed

20
Extensible Style Sheet Language
  • XSL is an XML language for describing a
    transformation
  • An XSL document describes a transformation that
    transforms XML documents into xHTML documents

21
XSL Format
ltxslstylesheet version"1.0"
xmlnsxsl"http//www.w3.org/TR/WD-xsl"gtltxsltemp
late match"/"gt HTML XML instructions lt/xslt
emplategtlt/xslstylesheetgt
22
XSL Markup
  • ltxslfor-each selectTAGgt ... lt/for-eachgt
  • selects each element in an XML document matching
    TAG and performs ...
  • ltxslvalue-of selectTAG /gt
  • Displays the value of TAG

23
addresses.xsl
lthtmlgtltheadgtlttitlegt Addresses lt/titlegtlt/headgtltbody
gtHere are your addressesltxslfor-each
select"addresses/person"gt ltbr /gtlthr /gt ltfont
color"red"gt ltbgtltigt name ltxslvalue-of
select"name"/gt lt/igtlt/bgt lt/fontgt ltbr /gt
phone ltxslvalue-of select"phone"/gtlt/xslfor-e
achgt ltbr /gtlthr /gtlt/bodygtlt/htmlgtlt/xsltemplategt
lt/xslstylesheetgt
24
book.xml (with an xsl)
lt?xml version"1.0"?gtlt!DOCTYPE addresses SYSTEM
"addresses.dtd"gtlt?xml-stylesheet type"text/xsl"
href"addresses.xsl"?gtltaddressesgt PERSON
PERSON PERSON ...lt/addressesgt
25
Displaying book.xml in IE (2)
Write a Comment
User Comments (0)
About PowerShow.com