supply chain & enterprise systems extensible markup language (xml) basics mis 6483 – spring...
TRANSCRIPT
Supply Chain & Enterprise Systems
eXtensible Markup Language (XML) Basics
MIS 6483 – Spring 2009www.suse1.astate.edu/~jseydel
Guest Instructor: John Seydel, Ph.D.
Student Objectives
Upon completion of this material you should be able to Describe the basics of what a markup language is
and how it works Discuss where XML fits as a markup language Identify opportunities to use XML as a data
wrapper Create XML files to be used in web applications Summarize several common uses of XML Discuss what a DTD does Identify several applications that currently use XML
Let’s Start with an Overview of Computer Languages Programming languages
Standalone Traditional (e.g., COBOL) Object-oriented (e.g., Java, VB.NET)
And/or scripting languages (rely on other components) JavaScript Others (e.g., PHP)
Markup languages (e.g., SGML, HTML, XHTML, DHTML)
Stylesheet languages (e.g., CSS, XSL) Database languages (e.g., SQL) How about XML . . . ?
Markup Languages: A High Level Perspective
HTM L
XHTM L M athM L GuestM L . . .
XM L Others
SGM L
Some Markup Basics: Sample HTML for a Starter Web Page<html>
<head><title>Home Page for Suzy Student</title>
</head><body>
<h1>Suzy Student</h1><h2>Welcome to My Website!</h2><p>
This site is currently under construction, so
please come back later.</p>
</body></html>
Summary of the Basic HTML Page Document contains
Title Page header Second level heading Short paragraph
Markup elements: html head body title h1 h2 p
Note the hierarchy
Refer to another example (see handout) . . .
eXtensible Markup Language XML facilitates the interchange of information
across disparate applications Not a markup language in itself; instead XML is a
meta language XML can be used to create customized markup
Generally not for web pages; exceptions Ajax (note the “X”) RSS feeds
Instead for applications; consider the file format used for Office 2007 documents Compressed XML files Surprisingly smaller than binary files
Note that XHTML is essentially just HTML reformulated to conform to XML specifications
XML requires more than HTML, in particular a processing application
Exercise: Look at Some XML Examples First, login locally as peachtree (password is
accounting2008) Microsoft PowerPoint 2007
Open PowerPoint Create a three slide presentation and save
someplace you’ll be able to find it Close PowerPoint and navigate to the file Is this XML?
Now, navigate to ASU’s home page Select “NEWS & EVENTS” Click on RSS View the source code
If possible, use RDC to look at SimNet data
XML Components A processing application
Parses the code and then does something with it Checks for well-formed documents May also validate
Includes one or more of the following Desktop application Web browser Other . . . ?
Code XML document DTD Stylesheet
CSS (preferred for the time being) XSL (not well supported yet)
Why a DTD? With XML, we can
Create our own markup language Use someone else’s markup
Thus, a DTD (i.e., DOCTYPE) can be used to ensure completeness and consistency Tells the user agent what the tags mean Provides syntax for the tags
Note: XML documents resemble HTML documents, but the tags are different The DTD for HTML is built into browsers User agents need to look externally for DTDs
for XML documents More later (if time permits)
Why Use XML? Makes data free of context Can do much more with it Not restricted to standard browsers Can render/process same set of data
numerous ways, depending upon the DTD employed
Allows for special purpose treatment of content (e.g., chemical formulae, house plans, etc.)
Hence Application integration through marked up
data Greater overall flexibility
A Sample XML Document
Language: RML (Recipe Markup Language)
Note XML declaration DTD for <recipe> element Content
How would this look?
Sample RML Document<?xml version=“1.0” encoding=“UTF-8”?><!DOCTYPE recipe SYSTEM “rml.dtd”><recipe cook=“JoJo Beans”>
<title>Bean Burrito</title><category name=“tex-mex” /><ingredients> <item>1 can refried beans </item> <item>1 small onion </item> <item> 3 flour tortillas</item></ingredients><cooking> Empty beans into saucepan and heat until beans are smooth. Then warm tortillas in microwave oven for 30 seconds.</cooking><serving>
Spread 1/3 of beans on each tortilla, sprinkle with onions, roll, and
serve.</serving>
</recipe>
Notice Some Things
General guidelines: XML declaration and DTD One tag contains all the others (root) All elements (including empty elements) have
start/end Elements are nested (e.g., item within
ingredient) Hierarchical Parent/child relationships
Attribute values quoted In other words, the same rules we should
be applying to HTML (i.e., XHTML) Consider another XML document . . .
Look Familiar?<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE
html PUBLIC "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“
><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title>Home Page for Suzy Student</title></head><body background="images/torch.gif">
<h1> <a href="http://www.astate.edu"> <img border="0" src="images/asu.gif" /> </a> Suzy Jo Student </h1> <h3><em>Welcome to my web site; Here's what you'll
find:</em></h3> . . .
</body></html>
An XML Exercise
Web application (Ajax) Involves
Local files to be editted; save in c:\xampp\htdocs HTML file (get from website) XML file (create in NotePad)
Remote files JavaScript CSS Images
Working version: www.suse1.astate.edu/~jseydel/handouts/xml_html.php
Now, the DTD
Can be within the XML document More often external Where can we find one to look at? How about ANY web page . . . ? Defines: elements, content,
attributes, parent/child, entities
DTDs Specify Element Declarations
General syntax <!ELEMENT name EMPTY> <!ELEMENT name #PCDATA> <!ELEMENT name child1,child2, . . . > <!ELEMENT name #PCDATA | child>
Consider XHTML elements img p ul div
Finally, Attribute Lists
General syntax<!ATTLIST attr1 attr2 CDATA #REQUIRED><!ATTLIST attr1 attr2 CDATA IMPLIED>
XHTML attributes (for <img> tag) src alt width height onMouseOver . . .
Summary of Objectives
Describe the basics of what a markup language is and how it works
Discuss where XML fits as a markup language Identify opportunities to use XML as a data
wrapper Create XML files to be used in web applications Summarize several common uses of XML Discuss what a DTD does Identify several applications that currently use
XML
Appendix
Facilitating B2B eCommerce
XML File for Ajax Example<?xml version="1.0" ?><root>
<data><row>
<cell>Name</cell><cell>Fruit</cell><cell>Vegetable</cell>
</row><row>
<cell>Captain</cell><cell>Banana</cell><cell>Zucchini</cell>
</row><row>
<cell>Admiral</cell><cell>Melon</cell><cell>Carrot</cell>
</row><row>
<cell>Midshipman</cell><cell>Orange</cell><cell>Potatoe</cell>
</row></data>
</root>
File Formats Supported by the Web
Basic Architecture of the Web
More Sophisticated Web Architecture