Title: eXtensible Markup Language (XML)
1ITEC 334 Fall 2008Computer Programming in the
Web Era
- eXtensible Markup Language (XML)
- Professor J. Alberto Espinosa
2Web Based Languages
- Hyper Text Markup Language (HTML)
- Text based description language used to create
Web pages, which is interpreted by Web Browsers - Text (data) is marked up with ltTAGSgt
- e.g. ltFONT COLORbluegtHello!!lt/FONTgt
- eXtensible Markup Language (XML)
- Like HTML, but used to specify/exchange data
- Text (data) is marked up with ltTAGSgt (like
HTML) - But tags are pre-defined for each application
- e.g. ltPRICEgt18.60lt/PRICEgt
ltCUSTOMERgtEspinosalt/CUSTOMERgt - XML processors retrieve and process the data(a
browser is an HTML processor)
HTML and XML are NOT software languages !!They
are page description languages
3Example Baking Bread with XML
- lt?xml version"1.0" encoding"UTF-8"?gt
- ltRecipe name"bread" prep_time"5 mins"
cook_time"3 hours"gt lttitlegtBasic breadlt/titlegt - ltingredient amount"3" unit"cups"gtFlourlt/ingredi
entgt ltingredient amount"0.25" unit"ounce"gtYeastlt
/ingredientgt ltingredient amount"1.5" unit"cups
state"warm"gtWaterlt/ingredientgt - ltingredient amount"1" unit"teaspoon"gtSaltlt/ingr
edientgt - ltInstructionsgt
- ltstepgtMix all ingredients together, and knead
thoroughly.lt/stepgt ltstepgtCover with a cloth, and
leave for one hour in warm room.lt/stepgt - ltstepgtKnead again, place in a tin, and then bake
in the oven.lt/stepgt - lt/Instructionsgt
- lt/Recipegt
4AnotherXMLExampleCan you draw a table that
contains the following data?
- ltCUSTOMERSgt
- ltCUSTOMERgt
- ltRECORDgt1lt/RECORDgt
- ltFIRSTNAMEgtAlbertolt/FIRSTNAMEgt
- ltLASTNAMEgtEspinosalt/LASTNAMEgt
- ltEMAILgtalberto_at_american.edult/EMAILgt
- ltPROFESSIONgtProfessorlt/PROFESSIONgt
- ltSCHOOLgtAmerican Universitylt/SCHOOLgt
- ltDEPARTMENTgtInformation Technologylt/DEPARTME
NTgt - ltREMARKSgtLooks tired, needs
vacationlt/REMARKSgt - lt/CUSTOMERgt
- ltCUSTOMERgt
- ltRECORDgt2lt/RECORDgt
- ltFIRSTNAMEgtGwanhoolt/FIRSTNAMEgt
- ltLASTNAMEgtLeelt/LASTNAMEgt
- ltEMAILgtglee_at_american.edult/EMAILgt
- ltPROFESSIONgtProfessorlt/PROFESSIONgt
5XML Data After Importing into a Database
6Business to Business E-Commerce Example using
XML
DBMS(e.g., MS SQL Server)
INSERT query
Supplier
XML Document (e.g., Purchase Order)
XML Processor
Internet
XML Processor
XML Document (e.g., Purchase Order)
Query results
Buyer
DBMS(e.g., Oracle)
SELECT query
7More About XML
- Document Type Definition (DTD) Documents
- Document used to define the meaning of tag used
in a particular XML document - A DTD can be embedded in the XML file itself
- Or in a separate .dtd file, which can be used in
multiple XML files - Specific industries (e.g., automotive, insurance,
etc.) have standard DTD files used to exchange
data (e.g. orders, invoices, catalogs) between
buyers and suppliers XML programmers for these
industries need to be familiar with these DTDs - eXtensible Stylesheet Language (XSL)
- Like Cascading Stylesheets (CSS)
- To format data displays on the browser