XML Overview2005 mcsd

Embed Size (px)

Citation preview

  • 8/14/2019 XML Overview2005 mcsd

    1/60

    XMLExtensible 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 UniversityE-Mail: [email protected]: 703-993-1788

    Fax: 703-993-1809

  • 8/14/2019 XML Overview2005 mcsd

    2/60

    XML - 2 Minder Chen 1996-2005

    Workshop Outline B2B E-Commerce

    XML Basics XML Document Type Definition, Schema, andData Type

    XSL (eXtensible Style Language) Access XML via Scripting and XML Document

    Object Model (DOM) Server-Side XML Processing

    XML Usage in B2B

  • 8/14/2019 XML Overview2005 mcsd

    3/60

    XML - 3 Minder Chen 1996-2005

    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/

    http://www.xml.com/http://www.xmlsoftware.com/http://www.w3.org/TR/1998/NOTE-XML-data/http://www.textuality.com/xml/http://www.textuality.com/xml/http://www.textuality.com/xml/http://www.textuality.com/xml/http://www.w3.org/TR/1998/NOTE-XML-data/http://www.xmlsoftware.com/http://www.xmlsoftware.com/http://www.xmlsoftware.com/http://www.xml.com/http://www.xml.com/http://www.xml.com/
  • 8/14/2019 XML Overview2005 mcsd

    4/60

    XML - 4 Minder Chen 1996-2005

    Blind Spots in the Chain of Commerce

  • 8/14/2019 XML Overview2005 mcsd

    5/60

    XML - 5 Minder Chen 1996-2005

    Review Identify Send Select Approve Set UpCatalogs Specifications RFP Vendor P.O. Credit

    Define Review Fill Out Send P.O.Requirements Vendors P.O. to Vendor

    Letter of Prepare Generate P.O.Credit/Terms Fulfillment Receipt

    CheckAvailability

    Arrange Send Receive PrepareShipping Order Order Invoice

    Tariffs/ InspectionsCustoms

    Post SendPayment Check

    Receive Invoice/Prepare Paymen

    SendInvoice

    Buying and Selling PrimitiveDocument / Data Interchange and Workflow Document / Data Interchange and Workflow

  • 8/14/2019 XML Overview2005 mcsd

    6/60

    XML - 6 Minder Chen 1996-2005

    Dell

  • 8/14/2019 XML Overview2005 mcsd

    7/60XML - 7 Minder Chen 1996-2005

    HTML and XML

    Plain English

    Course List:AITC offersIntr. to XML

    a basic-level courseon May 29, 1999Price $220at Reston Lab

    HTMLCourse ListCourse List

    AITC offers Intr. to XML basic-level

    May 29, 1999 Price $220 Reston Lab

    XMLAITCIntr. to XMLMay 29, 1999220

    Reston Lab

    Courselist.htm Courselist.xmlCourselist.doc

  • 8/14/2019 XML Overview2005 mcsd

    8/60XML - 8 Minder Chen 1996-2005

    XML Document Containing an Internal Document Type Definition

    ]>

    Minder Chen

    100 Main St.

    http://www.commerceone.com/xml/cbl/docs/purchaseorderdtdsamp .html

    http://www.myinfoage.com/http://eco.commerce.net/specs/index.cfm?content=spec.cfm&sec=3_5_3&rule=fts&output=fhttp://eco.commerce.net/specs/index.cfm?content=spec.cfm&sec=3_5_3&rule=fts&output=fhttp://www.myinfoage.com/
  • 8/14/2019 XML Overview2005 mcsd

    9/60XML - 9 Minder Chen 1996-2005

    XML Extensible Markup Language (XML) 1.0 W3C Recommendation 10-Feb-98

    XML 1.0Recommendation

    XML DTD

    XMLDocument

    For a specific type of documentsuch as a definition of PurchaseOrder's data structure. It is usedto validate XML document.

    For a specific document suchas a specific Purchase Order.

    A meta-language for definingXML DTD. XML Schema is acompeting standard.

  • 8/14/2019 XML Overview2005 mcsd

    10/60XML - 10 Minder Chen 1996-2005

    Document

    Structure Content Display

    Simple E-mail document

    Receiver: JohnSender: HarrySubject: Hello============================

    Dear John,Hello!

    ...This is the document for you!

    HarryMay 12, 1999

  • 8/14/2019 XML Overview2005 mcsd

    11/60XML - 11 Minder Chen 1996-2005

    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

    SGML

    HTML ...XML

    RDF CDF CML ...

  • 8/14/2019 XML Overview2005 mcsd

    12/60XML - 12 Minder Chen 1996-2005

    So, You Need More Than XML

    XMLdocument

    Document with

    Special Format(HTML/CSS)

    DTD

    Validation

    XSL

    Processing

    Structure

    Display C on t en t

    X M L P a r s

    e r

  • 8/14/2019 XML Overview2005 mcsd

    13/60XML - 13 Minder Chen 1996-2005

    HTML vs. XML

    HTML XML

    The markup describes the way inwhich the data is to be displayedin the browser.

    The markup describes the dataitself.

    Developers must use a limited setof predefined tags.

    Developers create tags and cantherefore describe any type of data.

    Searching for and updating data isdifficult because the same set of

    tags can be used for differenttypes of data.

    Searching for and updating datais easy because each type of

    data has a unique set of tagsthat define it.The way in which data is to bedisplayed in the browser iscontrolled.

    XML does not have any controlover the way data is displayed.

  • 8/14/2019 XML Overview2005 mcsd

    14/60XML - 14 Minder Chen 1996-2005

    Benefits from XML Extensible Markup Language is a text-based format that

    lets developers describe, deliver and exchangestructured data between a range of applications toclients 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

  • 8/14/2019 XML Overview2005 mcsd

    15/60XML - 15 Minder Chen 1996-2005

    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

  • 8/14/2019 XML Overview2005 mcsd

    16/60XML - 16 Minder Chen 1996-2005

    Sample XML Document

    ColumbineAquilegia canadensis

    A string literal was expected, but no opening quote

    character was found. Line 3, Position 13

    ------------^

  • 8/14/2019 XML Overview2005 mcsd

    17/60XML - 17 Minder Chen 1996-2005

    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 fewtouches that while small, have been crucial." XML is text, not binary. Superior error-handling Internationalization

    --- Tim Bray

  • 8/14/2019 XML Overview2005 mcsd

    18/60XML - 18 Minder Chen 1996-2005

    XML

    DTD

    HTML Resources XML

    Data

    Store

    Application

    XSL

    XPL

    HTML/CSS

    Display andReporting

    XLL

    XML DataTypes

    Data Transfer

    Definition and Structure

    Link to other resources

    XML Technologies

    XMLSchema

  • 8/14/2019 XML Overview2005 mcsd

    19/60XML - 19 Minder Chen 1996-2005

    XML Document: Namespaces Namespaces provide ways to mix XML tags without chaos Example:

    Description of gadget

    GadgetA gadget contains a big gizmo

  • 8/14/2019 XML Overview2005 mcsd

    20/60XML - 20 Minder Chen 1996-2005

    Creating XML Using XML Notepad You can find the latest information on XML Notepad at

    the Microsoft website at http://www.microsoft.com/

    http://www.microsoft.com/xmlhttp://www.microsoft.com/xml
  • 8/14/2019 XML Overview2005 mcsd

    21/60

    XML - 21 Minder Chen 1996-2005

    Source Document

    html100Introduction to HTML$200

    xml100Introduction to XML

    $250

  • 8/14/2019 XML Overview2005 mcsd

    22/60

  • 8/14/2019 XML Overview2005 mcsd

    23/60

    XML - 23 Minder Chen 1996-2005

    XML Document Structure

    Prologue:

    XML declaration Document Type Declaration

    (DOCTYPE)

    Processing Instructions and

    Comments

    Root Element and its child

    nodes

    Epilogue:

    Comments and

    Processing Instructions

  • 8/14/2019 XML Overview2005 mcsd

    24/60

    XML - 24 Minder Chen 1996-2005

    XML Document with an Internal DTD

    ]>

    Hello, world!

    Standalone attribute indicates whether external entities impactthe information passed to the processing application

    Internal DTD:

    A f T

  • 8/14/2019 XML Overview2005 mcsd

    25/60

    XML - 25 Minder Chen 1996-2005

    Anatomy of a Tag

    Opening tag

    AttributeClosingtag

    XML Tutorial

    XML Tutorial

    Element

  • 8/14/2019 XML Overview2005 mcsd

    26/60

    I C l b M P f l

  • 8/14/2019 XML Overview2005 mcsd

    27/60

    XML - 27 Minder Chen 1996-2005

    Its 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 isstructure correct important for business transaction document prevent from error or miscommunication

    An XML document is valid if it has an associateddocument type declaration and if the documentcomplies with the constraints expressed in it.

    The document type declaration must appear before the first element in the document.

    A XML ith E t l DTD

  • 8/14/2019 XML Overview2005 mcsd

    28/60

    XML - 28 Minder Chen 1996-2005

    An XML with an External DTDflower1.xml

    ColumbineAquilegia canadensis

    flower.dtd

    XML 1 0 R d ti

  • 8/14/2019 XML Overview2005 mcsd

    29/60

    XML - 29 Minder Chen 1996-2005

    XML 1.0 Recommendation [28] doctypedecl ::=

    '' [VC: Root Element Type]

    [29] markupdecl ::=elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment

    [VC: Proper Declaration/PE Nesting] [WFC: PEs in Internal Subset]

    fl 2 l P t DTD d XML i O Fil

  • 8/14/2019 XML Overview2005 mcsd

    30/60

    XML - 30 Minder Chen 1996-2005

    flower2.xml: Put DTD and XML in One File

    ]>

    ColumbineAquilegia canadensis

    htt // f tt k / l/1 lid t /XMLEdit ht

  • 8/14/2019 XML Overview2005 mcsd

    31/60

    XML - 31 Minder Chen 1996-2005

    http://www.nvcc-fasttrack.com/xml/1_validate/XMLEdit.htm

    flower3 xml: Plant List

  • 8/14/2019 XML Overview2005 mcsd

    32/60

    XML - 32 Minder Chen 1996-2005

    flower3.xml: Plant List

    ]>

    ColumbineAquilegia canadensis

    CowslipClatha palustris

    Well Formed XML and Valid XML

  • 8/14/2019 XML Overview2005 mcsd

    33/60

    XML - 33 Minder Chen 1996-2005

    Well-Formed XML and Valid XML

    Well-Formed XML:

    A well-formed XML document does notnecessarily include a DTD or a schema. Valid XML:

    XML that conforms to the vocabularyspecified 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

    XML Schema and Data Type

  • 8/14/2019 XML Overview2005 mcsd

    34/60

    XML - 34 Minder Chen 1996-2005

    XML- Schema and Data Type

    flower_schema.xml

    Style Language

  • 8/14/2019 XML Overview2005 mcsd

    35/60

    XML - 35 Minder Chen 1996-2005

    Style Language

    SGML DSSSL

    XMLXSL

    HTML CSS

    Contents of documents Style Language

    XSL (Extensible Style Language) defines the specificationfor an XML documents presentation and appearance.

    Standard: http://www.w3.org/TR/WD-xsl

    XML Presentation: XSL

  • 8/14/2019 XML Overview2005 mcsd

    36/60

    XML - 36 Minder Chen 1996-2005

    XML Presentation: XSL

    course.xml

    XSL Stylesheet

    XSLProcessor

    HTMLDocuments

    XMLDocuments

    HTMLBrowser

    XML + XSL => HTML Can be processed at either

    Server-Side or Client-Side

    XML class. . .

    XML . . .

    Sample XSL and XML

  • 8/14/2019 XML Overview2005 mcsd

    37/60

    XML - 37 Minder Chen 1996-2005

    Sample XSL and XMLgreeting.xmlHello World!

    greeting.xsl

    XML and XSL

  • 8/14/2019 XML Overview2005 mcsd

    38/60

    XML - 38 Minder Chen 1996-2005

    X M L a n

    d X S L

    p r o c e s s o

    r

    display

    Webserver Internet

    XML

    HTML

    XML

    (Browser-side add-onor building functions)

    ExtensibleStylesheetLanguage

    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 and XSL

    (Browser)XSL

    Client-Side

    XSL

  • 8/14/2019 XML Overview2005 mcsd

    39/60

    XML - 39 Minder Chen 1996-2005

    XSL

    Transfer well-formed XML documents toHTML documents Mapping

    Harry PorterHarry Porter

    Add some data to user Minder Chen AuthorMinder Chen

    Hide some data from user

    Integrating XML and XSL: product xsl3 xml

  • 8/14/2019 XML Overview2005 mcsd

    40/60

    XML - 40 Minder Chen 1996-2005

    Integrating XML and XSL: product_xsl3.xml

    html100Introduction to HTML

    $200

    xml100Introduction to XML$250

    XSL: for-each & value-of

  • 8/14/2019 XML Overview2005 mcsd

    41/60

    XML - 41 Minder Chen 1996-2005

    XSL: for-each & value-of

    Course Listing

    :
    Pirce:

    Action: applythe style to thetarget element

    Pattern: an XMLdocument'starget element

    Authoring Roles in XML Environments

  • 8/14/2019 XML Overview2005 mcsd

    42/60

    XML - 42 Minder Chen 1996-2005

    Authoring Roles in XML Environments

    Domain Experts

    Document TypeDefinition (DTD)

    Application

    Developers

    Presentation

    AuthorsContent

    ProvidersProcessing

    Applications XMLDocuments

    Stylesheets

    XML Parsing

  • 8/14/2019 XML Overview2005 mcsd

    43/60

    XML - 43 Minder Chen 1996-2005

    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 mechanismsare: DOM: Document Object Model

    SAX: Simple API for XML

    Client-Side XML Parsing Using JavaScript

  • 8/14/2019 XML Overview2005 mcsd

    44/60

    XML - 44 Minder Chen 1996-2005

    Client Side XML Parsing Using JavaScript

    IE 5.0

    XMLParser

    (msxml)

    HTML

    JavaScript Code

    Dynamic HTMLContainer:

    XML

    XMLTags & Data

    XMLObject Model

    Loading XML

    Document

    DOM

  • 8/14/2019 XML Overview2005 mcsd

    45/60

    XML - 45 Minder Chen 1996-2005

    DOM

    Shady GroveAeolian

    Over the River, CharlieDorian

    DOM specifies standard interface definitions for manipulating an XML document

    DOM APIs are platform specific

    mail xml

  • 8/14/2019 XML Overview2005 mcsd

    46/60

    XML - 46 Minder Chen 1996-2005

    mail.xml

    JodieBill

    Philip

    My first XML document

    Hello, World!

  • 8/14/2019 XML Overview2005 mcsd

    47/60

    XML - 47 Minder Chen 1996-2005

    HTML HEAD

    loadDoc();

    var rootElem;

    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;}

    Code Listing 2-2

    mail.htm

    Continued...

  • 8/14/2019 XML Overview2005 mcsd

    48/60

    XML - 48 Minder Chen 1996-2005

    Continued...

    To:


    From:


    Cc:


    Subject:


    Server-Side XML Processing

  • 8/14/2019 XML Overview2005 mcsd

    49/60

    XML - 49 Minder Chen 1996-2005

    NETWORK

    XMLParser

    ClientApplication

    ASPFile

    Passed over

    network as XML

    XML

    XML

    ASPFile

    Display usingclient-side

    data binding

    Updates originaldata source

    Database

    Updates onlymarshaled marshaled into

    XML by browser

    IE5 Browser

    CLIENT

    Data extractedfrom database

    ASP file usesserver-side parser

    to extract data

    SERVER

    Server Side XML Processing

    Server-side XML & XSL Processing

  • 8/14/2019 XML Overview2005 mcsd

    50/60

    XML - 50 Minder Chen 1996-2005

    Server side XML & XSL Processing Advantages: Browser independent; client only

    requires HTML support

    http://java.sun.com/xml/

    simple.xml

  • 8/14/2019 XML Overview2005 mcsd

    51/60

    XML - 51 Minder Chen 1996-2005

    simple.xml

    Belgian Waffles$5.95two of our famous Belgian Waffles with plenty of real maplesyrup

    650

    Strawberry Belgian Waffles$7.95light Belgian waffles coverred with strawberrys and whipped cream

    900

    Berry-Berry Belgian Waffles$8.95light Belgian waffles coverred with an assortment of fresh berries and whipped cream900

    French Toast$4.50thick slices made from our homemade sourdough bread600

    Homestyle Breakfast$6.95two eggs, bacon or sausage, toast, and our ever-popular hash browns950

  • 8/14/2019 XML Overview2005 mcsd

    52/60

    XML - 52 Minder Chen 1996-2005

    %// Error formatting function:function reportError(where, error){

    Response.Write("Error loading '" + where + "'" + error.reason + "");

    }// Load the XMLvar doc = Server.CreateObject("Microsoft.XMLDOM");var doc = Server.CreateObject("Microsoft.XMLDOM");doc.async = false;doc.async = false;doc.load(Server.MapPath("simple.xml"));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");var style = Server.CreateObject("Microsoft.XMLDOM");style.async = false;style.async = false;style.load(Server.MapPath("simple.xsl"));style.load(Server.MapPath("simple.xsl"));

    if (style.parseError.errorCode != 0){reportError("simple.xsl", doc.parseError);

    }// Process it

    var result = doc.transformNode(style);var result = doc.transformNode(style);Response.Write(result);Response.Write(result);

    }%>

    simple.asp

    Database and XML

  • 8/14/2019 XML Overview2005 mcsd

    53/60

    XML - 53 Minder Chen 1996-2005

    SERVER NETWORK

    XML XMLParser ClientApplicationDatabaseXML

    Converter

    CLIENT

    Use Server-sidescripting & Server-Side XML Parser

    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-Side XML Generated from a Database

  • 8/14/2019 XML Overview2005 mcsd

    54/60

    XML - 54 Minder Chen 1996-2005

    department.asp

    E-commerce DTDs

  • 8/14/2019 XML Overview2005 mcsd

    55/60

    XML - 55 Minder Chen 1996-2005

    Ad Markup, for Web advertisement

    AECMA Specification 1000D, for military document

    Biztalk, led by Microsoft, for MSN and Business to Customer system

    Microsofts 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

    Commerce Scenarios

  • 8/14/2019 XML Overview2005 mcsd

    56/60

    XML - 56 Minder Chen 1996-2005

    DistributorsDistributorsandand

    retailersretailers

    C or p or a t i on

    C or p or a t i on

    BusinessBusinesscustomerscustomers

    SuppliersSuppliersMROMRO

    Consumer Consumer

    44

    Extended value chainExtended value chain

    33

    Corporate purchasing (MRO)Corporate purchasing (MRO)

    2

    1111

    Business to consumer

    2

    (Business to business ) Selling to businesses

    SuppliersSuppliersValue chainValue chain

    B2C Data Exchange: Existing Methods - HTML Forms

  • 8/14/2019 XML Overview2005 mcsd

    57/60

    XML - 57 Minder Chen 1996-2005

    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 atserver or through client-side JavaScript

    Fixed interchange format

    B2B Data Exchange: Existing Methods - EDI messages

  • 8/14/2019 XML Overview2005 mcsd

    58/60

    XML - 58 Minder Chen 1996-2005

    UN standard format (EDIFACT) or X.12

    Compact strings, with numeric qualifiers. Strict limitation on thenumber of characters and position of data in a document.

    Example:

    UNH+900576+ORDERS:D:93A:UN:EAN007BGM+220+H940568DTM+137:19940201:102NAD+BY+5412345000176::9NAD+SU+4012345000094::9LIN+2PIA

    +5_1857990455:IBIMD+F+BAU+:::Farell J GIMD+F+BTI+:::The SingaporeGripQTY+21:1PRI+XXX:7.99UNS+SCNT+2:2UNT+15+900576

    Rules for data type control

    EDI and XML

  • 8/14/2019 XML Overview2005 mcsd

    59/60

    XML - 59 Minder Chen 1996-2005

    EDIVAN

    EDI EDI

    XML XML

    BizTalk

  • 8/14/2019 XML Overview2005 mcsd

    60/60