Title: Session Date: April 17, 2006
1Internet Supply Chain Management ECT 481
Spring 2006
Session Number 4
- Session Date April 17, 2006
- Session Outline
- Midterm Exam Highlights
- Project Info
- Session Topics XML
- XML Defined
- XML as a Content Development Tool
2Administrative Items
- Midterm Exam Highlights
- Project Teams Project Instructions
3XML - Mission Critical Terminology
- XML Defined
- A markup language for documents containing
structured information. - XML is really a meta-language for describing
markup languages. XML provides a facility to
define tags and the structural relationships
between them.
4XML Mission Critical Terminology (continued)
- Elements define common components of an XML
document. - Elements fall into three categories.
- those that define the structure of a document.
- those that specify the content of a document.
- those that apply formats to parts of documents.
- Attributes - is a specified behavioral
characteristic of an element. - Entity a named segment or piece of information
that can range from a single character to an
entire book consisting of packaged as one file.
5XML Mission Critical Terminology (continued)
- Markup - commands that define attributes, such
as formats enhancements, and describe the
documents. - Processing Instructions - part of the markup
that tells the XML processor or browser how to
handle an upcoming statement (or statements). - Style Sheets a set of instructions with which
document is formatted. - Document Type Declaration a declaration in an
XML document that points to or refers to a
document type definition (DTD). - Document Type refers to a class of documents,
including memos, letters, reports, manuals, etc. - Root Element is the top-level element in an
XML document.
6XML Essentials Documents, Elements,
Attributes
- XML is specified in XML documents.
- Elements are the fundamental building blocks of
XML documents. - Attributes specify the characteristics of
elements. - XML documents are made up of markup and
character data. - Markup is the instruction to the programs that
process and build XML documents. - Character data is everything else.
7XML Distinctions from SGML HTML (continued)
- SGML, HTML, XML share certain characteristics
- similar syntax
- the use of bracketed tags.
- XML HTML are descendants of SGML.
- XML is defined as an application profile of
SGML. SGML is the Standard Generalized Markup
Language defined by ISO 8879.
8XML Distinctions from SGML HTML
- SGML (Standard Generalized Markup Language)
provides arbitrary structure. - SGMLs too difficult to implement for a web
browser. - HTML comes bound with a set of semantics
- HTML does not provide arbitrary structure.
- XML is being designed to deliver structured
content over the web. - XML (unlike HTML) is strict and requires that
you follow specific W3C design guidelines.
9XML A Familiar Example
- Assume you have access to a computer that can
make food - The computer has stored in it the following
details - about the ingredients,
- how to cook things,
- how to serve, etc.
- Assume you loaded (scanned and OCRs) into the
computer a text version of an old-fashioned,
Good Housekeeping recipe, the computer may or
may not be able to read and decipher it.
10XML An Example (continued)
But if you gave loaded something like the
following, a smart XML parser in the computer
would know what ingredients to look for and then
know how to put them together and cook them.
ltrecipegt (has the makings of a root
element) lttitlegtDoughlt/titlegt
ltingredientsgt ltingred_amtgt1
cuplt/ingred_amtgt ltingredgtflourlt/ingredgt
ltingred_amtgt1 tsp.lt/ingred_amtgt lt
ingredgtsaltlt/ingredgt ltingred_amtgt1/2
cuplt/ingred_amtgt ltingredgtwaterlt/ingredgt
lt/ingredientsgt ltdirectionsgt
ltlistgt ltelementgtMix flour and salt.lt/elementgt
ltelementgtSlowly stir in
water until dough is moist.lt/elementgt
ltcookinggt ltelementgtPut in microwave safe
bowl.lt/elementgt
ltelementgtltmethodgtMicrowavelt/methodgt on
lttempgthighlt/tempgt for lttimegt10
minuteslt/timegtlt/elementgt
lt/cookinggt lt/listgt lt/directionsgt lt/recipegt
11XML Essentials DTDs
- A Document Type Definition (DTD) is a set of
syntax rules for tags. - DTDs tells you what each element means and how
to use it. - DTDs describe
- what tags you can use in a document.
- what order they should appear in.
- which tags can appear inside other ones.
- which tags have attributes.
- etc.
- DTDs can be internal to an XML document, but
it's usually a separate document or series of
documents. - A DTD is not required for an XML document to be
used in a web page, but DTDs add structure and
logic to an XML document.
12XML An Example (continued)
- Using the recipe example, we can create the
foundation of a DTD.
lt!DOCTYPE recipe lt!ELEMENT recipe (ingredients,
directions, body)gt lt!ELEMENT ingredients
(ingred_amt, ingred)gt lt!ELEMENT ingred_amt
(PCDATA)gt lt!ELEMENT ingred
(PCDATA)gt lt!ELEMENT directions (mix_instr,
cook_instr, method)gt lt!ELEMENT mix_instr
(PCDATA)gt lt!ELEMENT cook_instr
(PCDATA)gt lt!ELEMENT method
(PCDATA)gt lt!ENTITY wig Wow! Its good so easy
to make!gt gt ltrecipegt lttitlegtDoughlt/titlegt
ltingredientsgt ltingred_amt
gt1 cuplt/ingred_amtgt ltingredgtflourlt/ingredgt
ltingred_amtgt1
tsp.lt/ingred_amtgt ltingredgtsaltlt/ingredgt .
(etc.) . lt/recipegt
13XML Toolkit
- Authoring DTD Creation Tools
- Markup Tools
- Parsers
- Browsers
- Office Suites
- Application Development Environments
14XML Toolkit (continued) Product Options
15XML Application Development Process
- There are three steps to writing an XML
application. - First, identify which XML documents will be used
and how they will be accessed in the application.
- Each XML document can define its own set of
elements or tags. - Second, decide how the application will process
the XML document. - open the XML document and read it directly as a
file. - access the document through an XML parser (most
common approach). - note the parser usually makes the XML document
available as an event stream or as a tree
structure. - Finally, write the business logic that operates
on either the contents or the structure of the
XML data. For example - application that extracts email addresses from a
contact list. - application that simply reorder the elements of
each entry in the contact list.
16XML Application Development Process (continued)
- You can use a standard text editor to create
tags and content of your XML document or, you can
use an XML authoring tool. - If you load an XML document into IE5 with no
stylesheet at all, you get a nice tree-structured
display with little /- icons that you can click
to hide subtrees.
17XML Application Development Process (continued)
- You can use a standard text editor to create
tags and content of your XML document or, you can
use an XML authoring tool. - Display the document in an XML-friendly browser.
- If you load an XML document into IE5 with no
stylesheet at all, you get a nice tree-structured
display with little /- icons that you can click
to hide sub trees. - Supply display format instructions for the XML
document. - There are primarily two ways to format the
display of an XML document - Extensible Style Sheet (XSL), and
- Cascading Style Sheets (CSS)
- If you want to use style sheets, you have to
link the stylesheet to the document - For CSS lt?xml-stylesheet
type"text/css" hrefa_stylesheet.css" ?gt - For XSL lt?xml-stylesheet
type"text/xsl" hrefa_stylesheet.xsl" ?gt
18XML Application Scenarios
- Typically three types of XML applications
- Content Document Applications documents used to
exchange info. - Business Document Applications documents
representing business entities to be used by
people and in other business applications. - Protocol Document Applications documents
primarily used for the exchange of info among
applications.
19XML Application Scenarios Content Document
Applications
- XML used as substitute for HTML.
- Humans are principal consumers of these
documents. - Enables users to search metadata provided by XML
tags. - Enhances capability to personalize online
document delivery. - Enables users/viewers to perform local processing
on document content. - Development process resembles that of traditional
web applications. - Display style and format is very important.
- Examples include document archives, online news
service (I.e., WSJ Interactive), real estate
listing.
20XML Application Scenarios Business Document
Applications
- XML docs contain info about fundamental business
entities like customer, order, invoice, etc. - Humans and software apps are principal consumers
of business docs. - Enables and facilitates document workflow
automation. - Enables synthesis of actual documents from
existing business software. - Encourages standardization of inter-organizational
business document. - Requires tools to map XML elements to current
data models. - Development process heavily influenced by
business object modeling - Display style and format important but not as
much as in content apps. - Back-end system integration takes on more
importance. - Example applications include ERP/HR integration,
purchase authorization process automation,
academic research repository and info transfer.
21 XML Application Scenarios Protocol Document
Applications
- XML docs serve as the data encoding framework for
business protocols. - Software applications are primary consumers of
XML documents. - Heavy reliance on agreed-upon DTDs.
- Very low to non-existent display and formatting
requirement. - Development process resembles that for networked
file system I/O apps. - Typically document distribution engines serving
higher-level apps. - Example applications include electronic software
distribution (ESD), remote help desks.
22XML Development - The Basics
- Include an XML declaration as the first
statement in an XML document. - One tag (the root element) contains all of the
other tags. - Every element must have a start and an end tag.
- Empty elements must end in /gt
- (Empty elements do not hold content between the
start and end tags) - Nesting of tags follow the LIFO rule last tag
defined is the first tag closed. - All attribute values are closed in quotes.
- Tags and entities always begin the same way.
- Tags begin with less than (lt) sign.
- Entities begin with an ampersand () sign.
23XML Essentials DTD Composition
- DTDs consist of the following
- XML declaration tells the processor which
version of XML to use. - Document type declaration Tell the processor
where the DTD is located. - Element type declaration Defines the element
type. - Attribute list declaration defines the name,
data type, and default value (if any) of each
attribute associated with an element. - Entity declaration defines a set of
information that can be called by using its
entity name. - Notation declaration associates a notation
name with information that can help find an
interpreter of the notation.
24XML Entities (continued) Parameter Entity
Example
lt!- Segment from sample Order Form DTD -gt lt!-
Document Structure -gt lt!ELEMENT order (addresses,
lineitems, payment)gt . . lt!- Payment Structure
-gt lt!ELEMENT payment (card PO)gt . .lt!- Card
Structure -gt lt!ELEMENT card (cardholder, number,
expiration)gt lt!ELEMENT cardholder
(PCDATA)gt lt!ELEMENT number (PCDATA)gt lt!ELEMENT
expiration (PCDATA)gt . . lt!- Attribute Rules
-gt lt!ATTLIST card CARDTYPE (VISA Mastercard
Amex) REQUIREDgt
CARDTYPE might show up later in the document as
follows . . ltpaymentgt ltcard
CARDTYPEVISAgt ltcardholdergtJoe
Blowlt/cardholdergt ltnumbergt41280000000000lt/
numbergt ltexpirationgt01/03lt/expirationgt
lt/cardgt lt/paymentgt . . lt/ordergt
25XML Entities
- In general, an entity is used like an
abbreviation. - Entities are primarily structural elements.
- Whereas elements attributes enable
specification of logical meaning. - Associates an entity name with a content
fragment. - Four types
- Internal parsed allows definition of an alias
for text fragment. - External parsed enables inclusion of an entire
file as part of a document. - Unparsed enables insertion of arbitrary data
into a document. - Parameter enables creation of reusable and
extensible design elements in a DTD.
26Creating an XML Document
- Open an empty text file in a your text editor
(Notepad, Word, WordPad, Visual Studio text
editor, etc.) - Type in the contents/elements of your XML file.
- Save the file with a .xml extension.
- Double click the file to display it under IE5
(provided the extension is assigned to that
application). - IE5 has a built-in parser which will analyze
the document and display error detection
messages. - IE5 parser only checks to confirm well-formed
documents, not validity. - IE5 can be updated to provide validation. Go to
the following MS MSDN link. - Revise the file as needed.
27XML An Example (reprise)
- Using the recipe example, we can create the
foundation of a DTD.
lt!DOCTYPE recipe lt!ELEMENT recipe (title,
ingredients, directions, body)gt lt!ELEMENT Title
(PCCHAR) lt!ELEMENT ingredients (ingred_amt,
ingred)gt lt!ELEMENT ingred_amt
(PCDATA)gt lt!ELEMENT ingred
(PCDATA)gt lt!ELEMENT directions (mix_instr,
cook_instr, method)gt lt!ELEMENT mix_instr
(PCDATA)gt lt!ELEMENT cook_instr
(PCDATA)gt lt!ELEMENT method
(PCDATA)gt lt!ENTITY wig Wow! Its good so easy
to make!gt gt ltrecipegt lttitlegtDoughlt/titlegt
ltingredientsgt ltingred_amt
gt1 cuplt/ingred_amtgt ltingredgtflourlt/ingredgt
ltingred_amtgt1
tsp.lt/ingred_amtgt ltingredgtsaltlt/ingredgt .
(etc.) lt/recipegt
28Displaying an XML Document
- Display instructions are kept separate from the
XML document. - Benefits are enhanced flexibility and greater
change control. - There are primarily two ways to format the
display of an XML document - Cascading Style Sheets (CSS)
- a file that contains element formatting
instructions. - enables display of XML document w/o using HTML.
- Exstensible Stylesheet Language (XSL)
- Like CSS, XSL stylesheets provide a set of rules
for displaying tags. - XSL stylesheets are XML documents.
- XSL stylesheets require DTDs and act in similar
ways as other XML documents.
29Displaying an XML Document (continued)
- There are at least two other ways to display
XML documents. - Using Data Binding techniques
- Allows you to link an XML document to n HTML
page - You can then bind standard HTML elements (i.e.,
SPANs, TABLEs, etc.) to individual XML elements. - The bound HTML elements will then automatically
display the contents of the XML elements. - Using Document Object Model scripts
- Allows you to access an XML document that has
been linked to an HTML page using the Document
Object Model.
30XML Options for Displaying XML
31Distinguishing Well-formed Valid XML Documents
- XML puts a premium on the organization and
structure of documents. - Well-formed XML documents are well-organized and
accurate. - Well-formed documents provide a convenient means
for converting HTML to XML without writing and
conforming to a DTD. - Well-formed XML documents are not required to
meet some of the extra criteria to be discerned
as a valid XML document. - The main difference between a well-formed and
valid XML document is the absence or presence of
a DTD. - A valid XML document is well-formed (i.e.,
accurate can be parsed by a non-validating
parser) - and it must also include a DTD.
- The structure of the valid document must be
defined by the DTD.
32Distinguishing Well-formed Valid XML Documents
(continued)
Example of a Well-formed XML document
lt?xml version 1.0?gt ltMEMOgt ltTITLEgt Memo with
Logolt/TITLEgt ltLOGO srcsmalllogo.gif/gt ltTOgtECT
481 Studentslt/TOgt ltFROMgtEllis Conferlt/FROMgt ltSUBJE
CTgtMy Errorlt/SUBJECTgt ltBODYgt Somehow I
accidentally deleted the MEMO /MEMO tags from
the original display of this XML example. It is
fixed now.gt lt/BODYgt lt/MEMOgt
33Distinguishing Well-formed Valid XML Documents
(continued)
Example of a valid XML document
lt?xml version 1.0?gt lt!DOCTYPE MEMO
lt1ELEMENT MEMO (LOGO, TO, FROM, SUBSET,
BODY)gt lt!ELEMENT LOGO EMPTYgt lt!ELEMENT
TO (PCDATA)gt lt!ELEMENT FROM (PCDATA)gt lt!ELEMEN
T SUBJECT (PCDATA)gt lt!ELEMENT
BODY (PCDATA)gt gt ltMEMOgt ltTITLEgt Memo with
Logolt/TITLEgt ltLOGO srcsmalllogo.gif/gt ltTOgtECT
481 Studentslt/TOgt ltFROMgtEllis Conferlt/FROMgt ltSUBJE
CTgtMy Errorlt/SUBJECTgt ltBODYgt Somehow I
accidentally deleted the MEMO /MEMO tags from
the original display of this XML example. It is
fixed now.gt lt/BODYgt lt/MEMOgt
Inclusion of the DTD yields an XML document that
is not only well-formed but also valid.
34Next Session Highlights
- Midterm Administered
- XML (continued)
- Next Session Reading Assignment
- Review chapter 2 of Fitzgerald text
- Review articles (available thru the class notes
web site) - XML Matters (required)
- Free XML Tools by Category (FYI)
- Web sites (linked thru the class notes web site)
- Key XML Links