Applying XML - PowerPoint PPT Presentation

1 / 16
About This Presentation
Title:

Applying XML

Description:

If you feed this text to a computer, can it figure out that we ... XHTML is HTML that conforms to the rules of well-formed XML. XML-Based Programming Languages ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 17
Provided by: mark663
Category:
Tags: xml | applying

less

Transcript and Presenter's Notes

Title: Applying XML


1
Applying XML
  • Mark A. Cohen
  • Instructor of Computer Information Science
  • Lock Haven University
  • February 22, 2005

2
Computers Need Structure
  • Johnny Smith first entered this world on July 4th
    1969. He resides in Philadelphia, PA and is
    employed full-time with the National Parks
    Service.
  • If you feed this text to a computer, can it
    figure out that we are talking about a person
    named Johnny Smith. Can it tell where Johnny
    lives, works, or when he was born?

3
Proprietary Data Formats
  • To solve this problem software developers have
    created custom formats that have structure, and
    are therefore easier for computers to read
  • Each application often has its own custom format,
    and the format is often in binary form
  • Custom formats require custom parsers
  • Binary formats are hard for people to read
  • Binary formats can be platform specific
  • For programs to communicate, they need to be able
    to understand multiple formats and have multiple
    parsers

4
XML to the Rescue
  • XML adds structure text (by marking it up) so
    it can be read by a computer.
  • ltpersongtltfirstgtJohnnylt/firstgt ltlastgtSmithlt/lastgt
    first entered this world on ltdobgtJuly 4th
    1969lt/dobgt. He resides in ltlivesgtPhiladelphia,
    PAlt/livesgt and is employed full-time with the
    ltemployer typefull-timegtNational Parks
    Servicelt/employergtlt/persongt.

5
Advantages of XML
  • You only need one parser
  • Structure makes it easier to for computers to
    read and text-based so it is easy to read by
    humans
  • Text-based data is portable across platforms
  • Applications can talk more easily and share data
    if they speak the same language

6
The Parsing is Free!
  • Document doc db.parse(urlString)
  • Element elem doc.getDocumentElement()
  • NodeList nl elem.getElementsByTagName(first")
  • for (int n0 nltnl.getLength() n)
  • Element first (Element)nl.item(n)
  • System.out.pritnln
  • (first.getFirstChild())

7
Many Applications
  • The ability to parse data without having to write
    a parser is a wonderful thing. Just how
    wonderful can be demonstrated by looking at the
    many ways XML is being applied.
  • HTML?
  • New Programming Languages
  • Databases
  • Simple Remote Procedure Calls
  • Configuration Files
  • Transforming Data into Many Formats

8
Is HTML XML?
  • Is this valid HTML?
  • ltulgt
  • ltligtltpgtThe answer is yes!
  • lt/ulgt
  • Is it valid XML? The answer is no because it is
    not well-formed Not every tag has a closing tag.
    For this reason, parsing HTML is much harder
    than parsing XML.
  • XHTML is HTML that conforms to the rules of
    well-formed XML.

9
XML-Based Programming Languages
  • The ability to get a parser for free makes it
    really easy to create new programming languages.
  • The syntax checking is free
  • Language designers can focus on implementing the
    language
  • Since XML is a standard, XML based tools will
    work with any XML-based programming language

10
Scalable Vector Graphics (SVG)
  • ltsvggt
  • ltrect x"1" y"1"
  • width"1198" height"398"
  • fill"none"
  • stroke"blue"
  • stroke-width"2"gt
  • lt/rectgt
  • ltrect x"400" y"100"
  • width"400" height"200"
  • fill"yellow" strokeblue"
  • stroke-width"10" /gt
  • lt/rectgt
  • lt/svggt

You can viewing an SVG program in a web browser
by installing a free SVG viewer from
http//www.adobe.com/svg/viewer/install/
11
Jelly
  • ltjjelly xmlnsj"jellycore"gt
  • ltjchoosegt
  • ltjwhen test"user.locale'de_AT'"gt
  • Servus user.name
  • lt/jwhengt
  • ltjotherwisegt
  • Hello user.name
  • lt/jotherwisegt
  • lt/jchoosegt
  • lt/jjellygt

12
XML Database Queries
  • ltxsqlquery xmlnsxsql"urnoracle-xsql"gtSELECT
    name, ageFROM peopleWHERE name Tom
  • lt/xsqlquerygt
  • ltROWSETgt  ltROW num"1"gt    ltNAMEgtTomlt/NAMEgt    
    ltagegt21lt/agegt  lt/ROWgt
  • lt/ROWSETgt

13
Remote Procedure Calls
  • ltmethodCallgt
  • ltmethodNamegtgetPricelt/methodNamegt
  • ltparamsgt
  • ltparamgt
  • ltvaluegt
  • ltsymbolgtIBMlt/symbolgt
  • lt/valuegt
  • lt/paramgt
  • lt/paramsgt
  • lt/methodCallgt

14
Configuration Files
  • ltoutlookgt
  • ltprofile nameMarkgt
  • ltsendFormatgthtmllt/sendFormatgt
  • ltrecFormatgtplain-textlt/recFormatgt
  • ltfontgtCourier New 12ptlt/fontgt
  • ltdeleteOnClosegttruelt/deleteOnClosegt
  • ltmailfoldergtc\mail\marklt/mailfoldergt
  • lt/profilegt
  • ltprofile nameLisagt
  • ltsendFormatgtrtflt/sendFormatgt
  • ltrecFormatgtplain-textlt/recFormatgt
  • ltfontgtArial 10ptlt/fontgt
  • ltdeleteOnClosegttruelt/deleteOnClosegt
  • ltmailfoldergtc\mail\lisalt/mailfoldergt
  • lt/profilegt
  • lt/outlookgt

15
Easy Parsing Means Simple Transformations
Cohen, Mark Phone 111-2222 email
mark_at_b.c
ltcontactgt ltfirstgtMarklt/firstgt
ltlastgtCohenlt/lastgt ltphonegt111-2222lt/phonegt
ltemailgtmark_at_b.clt/emailgt lt/contactgt
Parse Transform
Mark Cohen can be reached at 111-2222, or via
email at mark_at_b.c.
ltpersongt ltnamegtMark Cohenlt/namegt lt/persongt
16
XSLT
  • Since transforming XML is so useful, a special
    XML-based programming language was created to
    simplify the task
  • ltxsltemplate matchfirstgt
  • For a good time call ltxslvalue-of
    select./gt!
  • lt/xsltemplategt
  • For a good time call Johnny!
Write a Comment
User Comments (0)
About PowerShow.com