Vous êtes sur la page 1sur 60

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: mchen@gmu.edu
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 Identify Send Select Approve Set Up


Catalogs Specifications RFP Vendor P.O. Credit

Define Review Fill Out Send P.O.


Requirements Vendors P.O. to Vendor

Check
Letter of Prepare Generate P.O. Availability
Credit/Terms Fulfillment Receipt
Send
Arrange Send Receive Prepare Invoice
Shipping Order Order Invoice
Receive Invoice/
Tariffs/ Inspections Post Send Prepare Payment
Customs Payment Check

© Minder Chen, 1996-2005 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 <?xml version="1.0" ?>
Course List: urse List</title></head> <courselist>
AITC offers <body> <course level="basic">
Intr. to XML <ol> <firm>AITC</firm>
a basic-level course <li>Course List <title>Intr. to XML</title>
on May 29, 1999 <ul> <date>May 29, 1999
Price $220 <li> AITC offers </date>
at Reston Lab <li> Intr. to XML <price currency="USD">
<li> basic-level 220
<li> May 29, 1999 </price>
<li> Price $220 <location>Reston Lab
<li> Reston Lab </location>
</ul> </course>
</ol> </courselist>
</body></html>
© 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

A meta-language for defining


XML 1.0 XML DTD. XML Schema is a
competing standard.
Recommendation

For a specific type of document


such as a definition of Purchase
Order's data structure. It is used
XML DTD to validate XML document.

For a specific document such


XML as a specific Purchase Order.
Document

© Minder Chen, 1996-2005 XML - 9


Document

• Structure
Simple E-mail document
• Content
• Display Receiver: John
Sender: Harry
Subject: Hello
============================
Dear John,
Hello!
………………...
This is the document for you!
Harry
May 12, 1999

© Minder Chen, 1996-2005 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

Instances /
Domains
RDF CDF CML ...

XML HTML ...

SGML
© Minder Chen, 1996-2005 XML - 11
So, You Need More Than XML…

DTD Structure r
s e
a r
P
Validation L
X M
Document with
XML Processing
document Special Format
(HTML/CSS)
Content

XSL Display

© Minder Chen, 1996-2005 XML - 12


HTML vs. XML
HTML XML

The markup describes the way in The markup describes the data
which the data is to be displayed itself.
in the browser.

Developers must use a limited set Developers create tags and can
of predefined tags. therefore describe any type of
data.
Searching for and updating data is Searching for and updating data
difficult because the same set of is easy because each type of
tags can be used for different data has a unique set of tags
types of data. that define it.
The way in which data is to be XML does not have any control
displayed in the browser is over the way data is displayed.
controlled.

© 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


XML XML Data
DTD Schema Types

Data Display and


Store Reporting
XML
Data Transfer XSL

Application HTML/CSS

XPL XLL Link to other


resources

HTML Resources XML

© Minder Chen, 1996-2005 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
<?xml version="1.0"?>
• Prologue:
– XML declaration <!DOCTYPE book SYSTEM
"bookreview.dtd” >
– Document Type Declaration
(DOCTYPE) <book>
– Processing Instructions and
<author> Jane Smith </author>
<review>
Comments
...
• Root Element and its child </review>
</book>
nodes

• Epilogue: <!-- “book” is the root


element.-->
– Comments and <?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
Closing
Opening tag 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> XML - 34
© Minder Chen, 1996-2005
Style Language
Contents of documents Style Language

SGML DSSSL

XML XSL

HTML 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
• XML + XSL => HTML
• Can be processed at either
Server-Side or Client-Side
XSL Stylesheet

XML
Documents

XSL HTML HTML


course.xml
Processor Documents Browser

<?xml version="1.0"?> <HTML>


<course> <BODY>
<name> XML </name> <b>XML</b> class
... ...
</course> </BODY>
</HTML>

© Minder Chen, 1996-2005 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 Client-Side

XML

XML and XSL


processor
Web
HTML
server Internet display

XSL (Browser)
Extensible
Stylesheet
Language (Browser-side add-on
or building functions)
© Minder Chen, 1996-2005 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
</HTML> the style to the
target element

© Minder Chen, 1996-2005 XML - 41


Authoring Roles in XML Environments
Domain Experts

Document Type
Definition (DTD) Presentation
Application
Authors
Developers
Content
Processing Providers 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 Object Model

XML
Dynamic HTML Parser
Container: (msxml)
• <DIV ID="X"></DIV>
• <SPAN ID="Y"></SPAN> XML
Tags & Data

© Minder Chen, 1996-2005 XML - 44


DOM
<TABLE> • DOM specifies standard interface definitions for
<TBODY> manipulating an XML document
• 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> XML - 48
© Minder Chen, 1996-2005
Server-Side XML Processing

SERVER CLIENT
Passed over
network as XML

Data extracted Display using


ASP client-side
from database XML
File data binding

Database Updates original


data source NETWORK Client
Application

IE5 Browser
XML ASP
Parser File Updates only
ASP file uses XML marshaled into
server-side parser XML by browser
to extract data

© Minder Chen, 1996-2005 XML - 49


Server-side XML & XSL Processing
• Advantages: Browser independent; client only
requires HTML support

Server-side scripting
Servlet or
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) simple.asp
{
Response.Write("<font face=Arial><B>Error loading '" + where + "'</B></font>
<BLOCKQUOTE><XMP>" + error.reason + "</XMP></BLOCKQUOTE>");
}
// Load the XML
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);
}
%> XML - 52
© Minder Chen, 1996-2005
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 NETWORK CLIENT

XML XML
Database Converter XML Parser
Client
Application

Use Server-side
scripting & Server-
Side 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
1
Suppliers
1 3

Corporation
Distributors MRO
and 2
retailers

Suppliers
Business
4 Value chain
customers 2
 Business to consumer
(Business to business)
 Selling to businesses
 Corporate purchasing (MRO)
 Extended value chain
© Minder Chen, 1996-2005 XML - 56
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’DT
M+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 EDI

XML XML

© Minder Chen, 1996-2005 XML - 59


BizTalk

© Minder Chen, 1996-2005 XML - 60

Vous aimerez peut-être aussi