XML
Extensible Markup Language: An Introduction
The Enabling Technology for
B2B eCommerce and Web Site Development
Minder Chen, Ph.D.
Associate Professor of Management Information Systems and Decision Sciences
School of Management, George Mason University
E-Mail: [email protected]
Phone: 703-993-1788
Fax: 703-993-1809
Workshop Outline
• B2B E-Commerce
• XML Basics
• XML Document Type Definition, Schema, and
Data Type
• XSL (eXtensible Style Language)
• Access XML via Scripting and XML Document
Object Model (DOM)
• Server-Side XML Processing
• XML Usage in B2B
© Minder Chen, 1996-2005
XML - 2
References
• William J. Pardi, XML in Action, Microsoft Press, 1999.
• Alex Homer, XML IE5: Programmer's Reference, WROX, 1999.
• Elliotte Rusty Harold, XML Bible, IDG Books, 2000.
• Online resources:
–
–
–
–
Our XML resources:
» http://65.168.115.6/xml/
Microsoft XML resources:
» http://msdn.microsoft.com/xml/
Dedicated XMl sites:
» http://www.xml.com/
and http://www.xmlsoftware.com/
XML-Data standard
» http://www.w3.org/TR/1998/NOTE-XML-data/
–
XML namespaces: http://www.w3.org/TR/REC-xml-names/
–
XSL standard:
http://www.w3.org/TR/1998/WD-xsl-19981216.pdf
The World Wide Web Consortium XML Workgroup:
http://www.w3.org/XML/Activity
Timothy Bray's (co-editor of the XML spec.) XML page
» http://www.textuality.com/xml/
–
–
© Minder Chen, 1996-2005
XML - 3
Blind Spots in the Chain of Commerce
© Minder Chen, 1996-2005
XML - 4
Buying and Selling– Primitive
Document / Data Interchange and Workflow
Review
Catalogs
Identify
Send
Specifications
RFP
Select
Approve
Vendor
P.O.
Define
Review
Fill Out
Requirements Vendors
P.O.
Letter of
Prepare
Credit/Terms Fulfillment
Arrange
Shipping
Send
Order
Prepare
Invoice
Tariffs/
Inspections
Customs
© Minder Chen, 1996-2005
Send P.O.
to Vendor
Check
Availability
Generate P.O.
Receipt
Receive
Order
Set Up
Credit
Post
Payment
Send
Invoice
Send
Check
Receive Invoice/
Prepare Payment
XML - 5
Dell
© Minder Chen, 1996-2005
XML - 6
HTML and XML
Courselist.doc
Courselist.htm
Courselist.xml
Plain English
HTML
XML
<html><head><title>Co
urse List</title></head>
<body>
<ol>
<li>Course List
<ul>
<li> AITC offers
<li> Intr. to XML
<li> basic-level
<li> May 29, 1999
<li> Price $220
<li> Reston Lab
</ul>
</ol>
</body></html>
<?xml version="1.0" ?>
<courselist>
<course level="basic">
<firm>AITC</firm>
<title>Intr. to XML</title>
<date>May 29, 1999
</date>
<price currency="USD">
220
</price>
<location>Reston Lab
</location>
</course>
</courselist>
Course List:
AITC offers
Intr. to XML
a basic-level course
on May 29, 1999
Price $220
at Reston Lab
© Minder Chen, 1996-2005
XML - 7
XML Document Containing an Internal Document Type Definition
<?xml version=“1.0” standalone=“yes” ?>
<!DOCTYPE person [
<!ELEMENT person
( name, street ) >
<!ELEMENT name
( #PCDATA ) >
<!ELEMENT street
( #PCDATA ) >
]>
<person>
<name> Minder Chen </name>
<street> 100 Main St. </street>
</person>
http://www.commerceone.com/xml/cbl/docs/purchaseorderdtdsamp.html
© Minder Chen, 1996-2005
XML - 8
XML
• Extensible Markup Language (XML) 1.0
• W3C Recommendation 10-Feb-98
XML 1.0
Recommendation
XML DTD
XML
Document
© Minder Chen, 1996-2005
A meta-language for defining
XML DTD. XML Schema is a
competing standard.
For a specific type of document
such as a definition of Purchase
Order's data structure. It is used to
validate XML document.
For a specific document such as
a specific Purchase Order.
XML - 9
Document
• Structure
• Content
• Display
© Minder Chen, 1996-2005
Simple E-mail document
Receiver: John
Sender: Harry
Subject: Hello
============================
Dear John,
Hello!
………………...
This is the document for you!
Harry
May 12, 1999
XML - 10
HTML, SGML and XML?
• Relations between HTML, SGML and XML:
– HTML is an implementation(instance) of SGML
– XML is an subset of SGML
– They are all languages for “document” processing
RDF CDF CML
Instances /
Domains
...
XML
HTML
...
SGML
© Minder Chen, 1996-2005
XML - 11
So, You Need More Than XML…
DTD
Structure
Validation
XML
document
Content
© Minder Chen, 1996-2005
Processing
XSL
Document with
Special Format
(HTML/CSS)
Display
XML - 12
HTML vs. XML
HTML
XML
The markup describes the way in
which the data is to be displayed
in the browser.
The markup describes the data
itself.
Developers must use a limited set
of predefined tags.
Developers create tags and can
therefore describe any type of
data.
Searching for and updating data is
difficult because the same set of
tags can be used for different
types of data.
Searching for and updating data
is easy because each type of
data has a unique set of tags
that define it.
The way in which data is to be
displayed in the browser is
controlled.
XML does not have any control
over the way data is displayed.
© Minder Chen, 1996-2005
XML - 13
Benefits from XML
• Extensible Markup Language is a text-based format that
lets developers describe, deliver and exchange
structured data between a range of applications to
clients for local display and manipulation.
• Information will be more accessible and reusable.
• XML brings so much power and flexibility to Web-based
applications for exchanging "
"
structured data
–
–
–
–
Data integration from disparate sources
Data from multiple applications
Local computation and manipulation of data
Multiple views on the data
More Meaningful searches
• Open Standards
• Format for Web delivery
–
–
Enhances scalability
Facilitates compression
© Minder Chen, 1996-2005
XML - 14
Well-Formed XML
•
•
•
•
•
•
Must start with an XML declaration
Non-empty tags must match and nest properly
Empty tags must end with />
Must have exactly one root element
Tag and attribute names are case-sensitive
Attribute values must be quoted
© Minder Chen, 1996-2005
XML - 15
Sample XML Document
<?xml version="1.0"?>
<PLANT ZONE="3">
<COMMON>Columbine</COMMON>
<BOTANICAL>Aquilegia canadensis</BOTANICAL>
</PLANT>
A string literal was expected, but no opening quote
character was found. Line 3, Position 13
<PLANT ZONE=3>
------------^
© Minder Chen, 1996-2005
XML - 16
So What!?
• "You guys look like a bunch of geniuses, and all
you did was say, 'Make the tags balance.' "
--- A Silicon Valley executive
• "There is really not much technology in XML,
and even less that is new. But there are a few
touches that while small, have been crucial."
– XML is text, not binary.
– Superior error-handling
– Internationalization
--- Tim Bray
© Minder Chen, 1996-2005
XML - 17
XML Technologies
Definition and Structure
DTD
XML Data
Types
XML
Schema
Data
Store
Display and
Reporting
XML
XSL
Data Transfer
Application
HTML/CSS
XPL XLL Link to other
resources
HTML
© Minder Chen, 1996-2005
Resources
XML
XML - 18
XML Document: Namespaces
• Namespaces provide ways to mix XML tags without chaos
• Example:
<widget xmlns="http://www.widget.org"
xmlns:xhtml="http://www.w3.org/TR/xhtml1"
type="gadget">
<head size="medium"/>
<big><subwidget ref="gizmo"/></big>
<info>
<xhtml:head>
<xhtml:title>Description of gadget</xhtml:title>
</xhtml:head>
<xhtml:body>
<xhtml:h1>Gadget</xhtml:h1>
A gadget contains a big gizmo
</xhtml:body>
</info>
</widget>
© Minder Chen, 1996-2005
XML - 19
Creating XML Using XML Notepad
• You can find the latest information on XML Notepad at
the Microsoft website at http://www.microsoft.com/
© Minder Chen, 1996-2005
XML - 20
Source Document
<PRODUCTLIST>
<PRODUCT>
<ID>html100</ID>
<NAME>Introduction to HTML</NAME>
<PRICE>$200</PRICE>
</PRODUCT>
<PRODUCT>
<ID>xml100</ID>
<NAME>Introduction to XML</NAME>
<PRICE>$250</PRICE>
</PRODUCT>
</PRODUCTLIST>
© Minder Chen, 1996-2005
XML - 21
XML Document: Validation
• You can enforce rules about these tags. Two kinds of
ways to define rules for the document. These rules can
be used to validate an XML document or used by XML
authoring tools to guide the creation of an XML
document.
– Document Type Definition (DTD): The XML
DTD contains or points to markup declarations that
provide a grammar for a class of documents. It uses
a special non-XML-based grammar
– XML Schema (XML-Data): This is a much richer
and more extensible way to describe the rules for
the content of a document and uses
XML itself
as a grammar.
© Minder Chen, 1996-2005
XML - 22
XML Document Structure
• Prologue:
– XML declaration
– Document Type Declaration
(DOCTYPE)
– Processing Instructions and
Comments
• Root Element and its child
nodes
• Epilogue:
– Comments and
<?xml version="1.0"?>
<!DOCTYPE book SYSTEM
"bookreview.dtd” >
<book>
<author> Jane Smith </author>
<review>
...
</review>
</book>
<!-- “book” is the root
element.-->
<?imgsize size=“200,200” ?>
– Processing Instructions
© Minder Chen, 1996-2005
XML - 23
XML Document with an Internal DTD
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE greeting [
<!ELEMENT greeting (#PCDATA)>
]>
<greeting>Hello, world!</greeting>
Internal DTD:
<!DOCTYPE rootElement [ elementDeclarations ]>
Standalone attribute indicates whether external entities impact
the information passed to the processing application
© Minder Chen, 1996-2005
XML - 24
Anatomy of a Tag
<H1 ALIGN="CENTER"> XML Tutorial </H1>
<H1 ALIGN="CENTER"> XML Tutorial </H1>
Attribute
Opening tag
Closing
tag
Element
© Minder Chen, 1996-2005
XML - 25
DTD (Document Type Definition)
• DTD defines the valid structure of XML document rules
such as:
• Valid element names
<BOOK><TITLE><AUTHOR><PRICE><ISBN>
• Valid attribute names and values
<AUTHOR id="234" gender="F">
• Relationship between elements (Child elements)
<BOOK>
<TITLE>...</TITLE>
<AUTHOR>...</AUTHOR>
…………...
</BOOK>
• DTD can be included within XML document or included from
other file/document
© Minder Chen, 1996-2005
XML - 26
It’s Complex, but More Powerful
• With DTD you can…
– Define your own more meaningful tags
» easy to read
» easy to search
» easy to transform to other formats
– You can validate whether your document is
structure correct
» important for business transaction document
» prevent from error or miscommunication
• An XML document is valid if it has an associated
document type declaration and if the document
complies with the constraints expressed in it.
• The document type declaration must appear before
the first element in the document.
© Minder Chen, 1996-2005
XML - 27
An XML with an External DTD
flower1.xml
<?xml version="1.0"?>
<!DOCTYPE PLANT SYSTEM "flower.dtd">
<PLANT ZONE="3">
<COMMON>Columbine</COMMON>
<BOTANICAL>Aquilegia canadensis</BOTANICAL>
</PLANT>
flower.dtd
<?xml version="1.0"?>
<!ELEMENT PLANT (COMMON, BOTANICAL)>
<!ATTLIST PLANT ZONE CDATA #IMPLIED>
<!ELEMENT COMMON (#PCDATA)>
<!ELEMENT BOTANICAL (#PCDATA)>
© Minder Chen, 1996-2005
XML - 28
XML 1.0 Recommendation
• [28] doctypedecl ::=
'<!DOCTYPE' S Name (S ExternalID)? S? ('[' (markupdecl |
PEReference | S)*']' S?)? '>'
– [VC: Root Element Type]
• [29] markupdecl ::=
elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment
– [VC: Proper Declaration/PE Nesting]
– [WFC: PEs in Internal Subset]
© Minder Chen, 1996-2005
XML - 29
flower2.xml: Put DTD and XML in One File
<?xml version="1.0"?>
<!DOCTYPE PLANT [
<!ELEMENT PLANT (COMMON, BOTANICAL)>
<!ATTLIST PLANT ZONE CDATA #IMPLIED>
<!ELEMENT COMMON (#PCDATA)>
<!ELEMENT BOTANICAL (#PCDATA)>
]>
<PLANT ZONE="3">
<COMMON>Columbine</COMMON>
<BOTANICAL>Aquilegia canadensis</BOTANICAL>
</PLANT>
© Minder Chen, 1996-2005
XML - 30
http://www.nvcc-fasttrack.com/xml/1_validate/XMLEdit.htm
© Minder Chen, 1996-2005
XML - 31
flower3.xml: Plant List
<?xml version="1.0"?>
<!DOCTYPE PLANTLIST [
<!ELEMENT PLANTLIST (PLANT+)>
<!ELEMENT PLANT (COMMON, BOTANICAL)>
<!ATTLIST PLANT ZONE CDATA #IMPLIED>
<!ELEMENT COMMON (#PCDATA)>
<!ELEMENT BOTANICAL (#PCDATA)>
]>
<PLANTLIST>
<PLANT ZONE="3">
<COMMON>Columbine</COMMON>
<BOTANICAL>Aquilegia canadensis</BOTANICAL>
</PLANT>
<PLANT ZONE="2">
<COMMON>Cowslip</COMMON>
<BOTANICAL>Clatha palustris</BOTANICAL>
</PLANT>
</PLANTLIST>
© Minder Chen, 1996-2005
XML - 32
Well-Formed XML and Valid XML
• Well-Formed XML:
– A well-formed XML document does not
necessarily include a DTD or a schema.
• Valid XML:
– XML that conforms to the vocabulary
specified in a DTD or schema.
• Document processing performance:
–
Well-formedness is an attribute of all XML documents
–
Well-formedness parsing is very fast
–
Validation can be time consuming and is specific to a
particular application based on the DTY or Schema
© Minder Chen, 1996-2005
XML - 33
XML- Schema and Data Type
flower_schema.xml
<Schema name="PLANTLIST"
xmlns="urn:schemas-microsoft-com:xml-data"
xmlns:dt="urn:schema-microsoft-com:datatypes">
<ElementType name="COMMON" content="textOnly"/>
<ElementType name="BOTANICAL" content="textOnly"/>
<AttributeType name="BESTSELLER" dt:type="enumeration"
dt:values="yes no" default="no" />
<ElementType name="PLANT">
<element type="COMMON"/>
<element type="BOTANICAL"/>
<attribute type="BESTSELLER"/>
</ElementType>
<ElementType name="PLANTLIST" content="eltOnly" model="closed">
<element type="PLANT" minOccurs="1" maxOccurs="*" />
</ElementType>
</Schema>
© Minder Chen, 1996-2005
XML - 34
Style Language
Contents of documents
SGML
XML
HTML
Style Language
DSSSL
XSL
CSS
XSL (Extensible Style Language) defines the specification
for an XML document’s presentation and appearance.
Standard: http://www.w3.org/TR/WD-xsl
© Minder Chen, 1996-2005
XML - 35
XML Presentation: XSL
XSL Stylesheet
•
XML + XSL => HTML
•
Can be processed at either
Server-Side or Client-Side
XML
Documents
course.xml
<?xml version="1.0"?>
<course>
<name> XML </name>
...
</course>
© Minder Chen, 1996-2005
XSL
HTML
HTML
Processor
Documents
Browser
<HTML>
<BODY>
<b>XML</b> class
...
</BODY>
</HTML>
XML - 36
Sample XSL and XML
greeting.xml
<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet href="greeting.xsl" type="text/xsl" ?>
<greeting>
Hello World!
</greeting>
greeting.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<H1> <xsl:value-of /> </H1>
</xsl:template>
</xsl:stylesheet>
© Minder Chen, 1996-2005
XML - 37
XML and XSL
XML deals only with the data structures and contents of a document
XSL specifies rules to convert XML patterns to HTML tags and contents
XML
XML
Web
server
Extensible
Stylesheet
Language
© Minder Chen, 1996-2005
Internet
XSL
XML and XSL
processor
Client-Side
HTML
display
(Browser)
(Browser-side add-on
or building functions)
XML - 38
XSL
• Transfer well-formed XML documents to
HTML documents
– Mapping
<book_title>Harry Porter</book_title>
<H1>Harry Porter</H1>
– Add some data to user
<book_author>Minder Chen<book_author>
<H2>Author</H2><SPAN>Minder Chen</SPAN>
– Hide some data from user
© Minder Chen, 1996-2005
XML - 39
Integrating XML and XSL: product_xsl3.xml
<?xml version='1.0'?>
<?xml:stylesheet type="text/xsl" href="product_xsl3.xsl" ?>
<PRODUCTLIST>
<PRODUCT>
<ID>html100</ID>
<NAME>Introduction to HTML</NAME>
<PRICE>$200</PRICE>
</PRODUCT>
<PRODUCT>
<ID>xml100</ID>
<NAME>Introduction to XML</NAME>
<PRICE>$250</PRICE>
</PRODUCT>
</PRODUCTLIST>
© Minder Chen, 1996-2005
XML - 40
XSL: for-each & value-of
<?xml version="1.0"?>
<HTML xmlns:xsl=
"http://www.w3.org/TR/WD-xsl"> Pattern: an XML
document's
<BODY>
target element
<H1> Course Listing </H1>
<xsl:for-each select="PRODUCTLIST/PRODUCT">
<xsl:value-of select="ID"/> :
<b><xsl:value-of select="NAME"/></b> <br/>
<i> Pirce: <xsl:value-of select="PRICE"/></i> <hr/>
</xsl:for-each>
</BODY>
Action: apply
the style to the
</HTML>
target element
© Minder Chen, 1996-2005
XML - 41
Authoring Roles in XML Environments
Domain Experts
Document Type
Application
Definition (DTD)
Presentation
Authors
Developers
Content
Providers
Processing
Stylesheets
Applications
XML
Documents
© Minder Chen, 1996-2005
XML - 42
XML Parsing
• Parsing is the process of analyzing the
structure of an XML document.
• Parsing can be done on either client-side or
server-side.
• There are nonvalidating parsers and validating
parsers.
• Two popular API for XML parsing mechanisms
are:
– DOM: Document Object Model
– SAX: Simple API for XML
© Minder Chen, 1996-2005
XML - 43
Client-Side XML Parsing Using JavaScript
XML
Loading XML
Document
IE 5.0
HTML
XML
JavaScript Code
Dynamic HTML
Container:
• <DIV ID="X"></DIV>
• <SPAN ID="Y"></SPAN>
© Minder Chen, 1996-2005
Object Model
XML
Parser
(msxml)
XML
Tags & Data
XML - 44
DOM
• DOM specifies standard interface definitions for
<TABLE>
manipulating an XML document
<TBODY>
• DOM APIs are platform specific
<TR>
<TD>Shady Grove</TD>
<TD>Aeolian</TD>
</TR>
<TR>
<TD>Over the River, Charlie</TD>
<TD>Dorian</TD>
</TR>
</TBODY>
</TABLE>
© Minder Chen, 1996-2005
XML - 45
mail.xml
<?xml version="1.0" ?>
<MEMO>
<TO>Jodie</TO>
<FROM>Bill</FROM>
<CC>Philip</CC>
<SUBJECT>My first XML document</SUBJECT>
<BODY>Hello, World!</BODY> </MEMO>
© Minder Chen, 1996-2005
XML - 46
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML> <HEAD>
<SCRIPT LANGUAGE="JavaScript" FOR=window EVENT=onload>
loadDoc();
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var rootElem;
mail.htm
var xmlDoc = new ActiveXObject("microsoft.xmldom");
xmlDoc.load("mail.xml");
function loadDoc()
{
if (xmlDoc.readyState == "4")
start();
else
window.setTimeout("loadDoc()", 4000)
}
function start()
{
rootElem = xmlDoc.documentElement;
todata.innerText = rootElem.childNodes.item(0).text;
fromdata.innerText=rootElem.childNodes.item(1).text;
ccdata.innerText=rootElem.childNodes.item(2).text;
subjectdata.innerText=rootElem.childNodes.item(3).text;
bodydata.innerText=rootElem.childNodes.item(4).text;
}
</SCRIPT>
<TITLE>Code Listing 2-2</TITLE> </HEAD>
© Minder Chen, 1996-2005
XML - 47
Continued...
<BODY>
<DIV ID="to" STYLE="font-weight:bold;font-size:16">
To:
<SPAN ID="todata" STYLE="font-weight:normal"></SPAN>
</DIV>
<BR>
<DIV ID="from" STYLE="font-weight:bold;font-size:16">
From:
<SPAN ID="fromdata" STYLE="font-weight:normal"></SPAN>
</DIV>
<BR>
<DIV ID="cc" STYLE="font-weight:bold;font-size:16">
Cc:
<SPAN ID="ccdata" STYLE="font-weight:normal"></SPAN>
</DIV>
<BR>
<DIV ID="subject" STYLE="font-weight:bold;font-size:16">
Subject:
<SPAN ID="subjectdata" STYLE="font-weight:normal"></SPAN>
</DIV>
<BR>
<HR>
<SPAN ID="bodydata" STYLE="font-weight:normal"></SPAN>
</BODY>
</HTML>
© Minder Chen, 1996-2005
XML - 48
Server-Side XML Processing
SERVER
Data extracted
from database
Database
CLIENT
Passed over
network as XML
ASP
File
XML
Updates original
data source
NETWORK
Display using
client-side
data binding
Client
Application
IE5 Browser
XML
Parser
ASP
File
ASP file uses
server-side parser
to extract data
© Minder Chen, 1996-2005
XML
Updates only
marshaled into
XML by browser
XML - 49
Server-side XML & XSL Processing
• Advantages: Browser independent; client only
requires HTML support
http://java.sun.com/xml/
© Minder Chen, 1996-2005
XML - 50
simple.xml
<?xml version='1.0'?>
<?xml:stylesheet type="text/xsl" href="simple.xsl" ?>
<breakfast-menu>
<food>
<name>Belgian Waffles</name>
<price>$5.95</price>
<description>two of our famous Belgian Waffles with plenty of real maple
syrup</description>
<calories>650</calories>
</food>
<food>
<name>Strawberry Belgian Waffles</name>
<price>$7.95</price>
<description>light Belgian waffles coverred with strawberrys and whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>Berry-Berry Belgian Waffles</name>
<price>$8.95</price>
<description>light Belgian waffles coverred with an assortment of fresh berries and whipped cream</description>
<calories>900</calories>
</food>
<food>
<name>French Toast</name>
<price>$4.50</price>
<description>thick slices made from our homemade sourdough bread</description>
<calories>600</calories>
</food>
<food>
<name>Homestyle Breakfast</name>
<price>$6.95</price>
<description>two eggs, bacon or sausage, toast, and our ever-popular hash browns</description>
<calories>950</calories>
</food>
</breakfast-menu>
© Minder Chen, 1996-2005
XML - 51
<%@ LANGUAGE = JScript %>
<%
// Error formatting function:
function reportError(where, error)
{
Response.Write("<font face=Arial><B>Error loading '" + where + "'</B></font> <BLOCKQUOTE><XMP>"
+ error.reason + "</XMP></BLOCKQUOTE>");
}
// Load the XML
simple.asp
var doc = Server.CreateObject("Microsoft.XMLDOM");
doc.async = false;
doc.load(Server.MapPath("simple.xml"));
if (doc.parseError.errorCode != 0)
{
reportError("simple.xml", doc.parseError);
}
else
{
// Load the stylesheet
var style = Server.CreateObject("Microsoft.XMLDOM");
style.async = false;
style.load(Server.MapPath("simple.xsl"));
if (style.parseError.errorCode != 0)
{
reportError("simple.xsl", doc.parseError);
}
// Process it
var result = doc.transformNode(style);
Response.Write(result);
}
%>
© Minder Chen, 1996-2005
XML - 52
Database and XML
• Convert database data into XML
• Store native XML documents in the database
• Parse receive XML document and store the extracted data into
database
• XML servers provide database functions over XML documents.
SERVER
Database
XML
Converter
NETWORK
XML
CLIENT
XML
Parser
Client
Application
Use Server-side
scripting & ServerSide XML Parser
© Minder Chen, 1996-2005
XML - 53
Server-Side XML Generated from a Database
<?xml version="1.0"?>
<departmentlist>
department.asp
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "expense"
Set DeptRS = Conn.Execute("select * from departments")
Do While Not DeptRS.EOF
%>
<department>
<ID><%=DeptRS("Id")%></ID>
<NAME><%=DeptRS("Name")%></NAME>
<DESCRIPTION>
<%=DeptRS("Description")%>
</DESCRIPTION>
</department>
<%
DeptRS.MoveNext
Loop
%>
</departmentlist>
© Minder Chen, 1996-2005
XML - 54
E-commerce DTDs …
• Ad Markup,
–
for Web advertisement
• AECMA Specification 1000D,
–
for military document
• Biztalk,
–
led by Microsoft, for MSN and Business to Customer system
• Microsoft’s CDF,
–
channel ‘push’ technology
• Commerce XML (cXML),
–
for catalog, product and transaction data
• Information and Content Exchange (ICE),
–
for sharing management information between partners
http://www.oasis-open.org/cover/xml.html#applications
© Minder Chen, 1996-2005
XML - 55
Commerce Scenarios
Consumer
Business
customers
Distributors
and
retailers
2
Corporation
1
1
3
Suppliers
4
Suppliers
2
 Business to consumer
(Business to business)
 Selling to businesses
 Corporate purchasing (MRO)
 Extended value chain
© Minder Chen, 1996-2005
XML - 56
MRO
Value chain
B2C Data Exchange: Existing Methods - HTML Forms
• Can include most other HTML elements
• Limited set of field types
– Single line input fields
» text/password, checkbox/radio, submit/reset, file/image,
hidden
– Multiple line text areas
– Selection menus
» can include pre-selected options
• Data type checking usually is done at
server or through client-side JavaScript
• Fixed interchange format
© Minder Chen, 1996-2005
XML - 57
B2B Data Exchange: Existing Methods - EDI messages
• UN standard format (EDIFACT) or X.12
• Compact strings, with numeric qualifiers. Strict limitation on the
number of characters and position of data in a document.
• Example:
• UNH+900576+ORDERS:D:93A:UN:EAN007’BGM+220+H940568’DTM
+137:19940201:102’
NAD+BY+5412345000176::9’NAD+SU+4012345000094::9’LIN+2’PIA
+5_1857990455:IB’
IMD+F+BAU+:::Farell J G’IMD+F+BTI+:::The Singapore
Grip’QTY+21:1’
PRI+XXX:7.99’UNS+S’CNT+2:2’UNT+15+900576’
• Rules for data type control
© Minder Chen, 1996-2005
XML - 58
EDI and XML
EDI
VAN
EDI
XML
© Minder Chen, 1996-2005
EDI
XML
XML - 59
BizTalk
© Minder Chen, 1996-2005
XML - 60
Descargar

EDI Defined - George Mason University