530 likes | 695 Views
eCommerce Technology 20-751 Lecture 8: Data Interchange. Outline. The need for data interchange Transactions imply data exchange The XML concept Separation of content presentation document structure ASN.1 for self-describing data formats Solves a different problem than XML does
E N D
Outline • The need for data interchange • Transactions imply data exchange • The XML concept • Separation of • content • presentation • document structure • ASN.1 for self-describing data formats • Solves a different problem than XML does • Not what the data means but how it is encoded
Data Exchange in eCommerce Process CreditCard ChooseVendor Select& Order B2C Ship Review Catalogs IdentifySpecifications Send RFP Select Vendor ApproveP.O. Set Up Credit B2B Define Requirements Fill Out P.O. Send P.O. to Vendor Review Vendors Check Availability Generate P.O. Receipt Prepare Fulfillment Letter of Credit / Terms Send Invoice Prepare Invoice Receive Order Send Order Inspections Receive Invoice / Prepare Payment Arrange Shipping Post Payment Send Check Tariffs / Customs SOURCE: METALSITE
1 2 Purchase Order Order Receipt Quotes Prices Incorrect Revise Data 7 Order Delay? X 6 3 Error Resolution Notification of Error ? 4 Adjust Invoice Adjust Payables 9 5 Invoice Receipt Send Invoice 8 X 12 10 11 Payment w/Deduction Payment Recv’d Allow Deduct? IF Corrected IF NOT Corrected Allow or Issue Credit 14 13 Credit Taken Credit Memo Typical Purchase to Payment Cycle Distributor Manufacturer
“Any meaningful exchange of utterances depends upon the prior existence of an agreed upon set of semantic and syntactic rules” ISO TR9007:1987 Information Processing Systems – Concepts and Technology for the Conceptual Schema and the Information Base Basis for Communication
Invoice Example <UnitPrice>6.05</UnitPrice> SOURCE: PROF. JEROME YEN
Components of Data Presentation Structure ABC Content Text Pictures SOURCE: SOFTWARE AG
How to Make Data Portable • Tell what the data is • Tell how the data is structured • Tell how it should look • BUT DO THESE SEPARATELY. MIXING IS BAD • The meaning -- XML • The structure -- XML Schema (document type definition) • The formatting -- XSL (eXtensible style sheet language) • Example: XML catalog structure • DTD, XSL SO COMPUTERS CAN UNDERSTAND IT
XML at a glance Well Formed Document (obeys XML syntax rules): <Book> <Author>George Soros</Author> <Title>The Crisis of Global Capitalism</Title> <Year>1998</Year> <Publ>Public Affairs</Publ> <Price>26.00</Price> <ISBN>1-891620-27-4</ISBN> </Book> SOURCE: PROF. JEROME YEN
XML Recipe Example <?xml version="1.0"?><Recipe> <Name>Apple Pie</Name> <Ingredients> <Ingredient> <Qty unit=pint>1</Qty> <Item>milk</Item> </Ingredient> <Ingredient> <Qty unit=each>10</Qty> <Item>apples</Item> </Ingredient> </Ingredients> <Instructions> <Step>Peel the apples</Step> <Step>Pour the milk into a 10-inch saucepan</Step> <!-- And so on... --> </Instructions></Recipe>
Document Is Now Tree-Structured <?xml version="1.0"?><Recipe> <Name>Apple Pie</Name> <Ingredients> <Ingredient> <Qty unit=pint>1</Qty> <Item>milk</Item> </Ingredient> <Ingredient> <Qty unit=each>10</Qty> <Item>apples</Item> </Ingredient> </Ingredients> <Instructions> <Step>Peel the apples</Step> <Step>Pour the milk into a 10-inch saucepan</Step> <!-- And so on... --> </Instructions></Recipe>
An XML Document is a Tree BOOKLIST BOOK BOOK TITLE YEAR AUTHOR PUBLISHER Each XML element and subelement is a node
XMLDOMDocument XMLDOMNode XML Document Tree Element Attribute Value Document CATALOG WIDGET WIDGET ID ID 1 2 NAME PRICE NAME PRICE CURRENCY CURRENCY Widget 1 10 20 Widget 2 USD USD SOURCE: MICROSOFT
XML Namespaces • Two different elements with the same name will cause confusion
This is a table of fruits This is a physical table They have different sets of subelements Sets of Tags Might Conflict • Example:
Tags in the h namespace In the h namespace, table has subelements tr, td In the f namespace, table has subelements name, width, length Tags in the f namespace Namespaces • Example:
Namespaces External references to namespace definitions
XML Sample Document <?xml version=“1.0” encoding=“UTF-8” ?> <catalog, schemalocation = “http://euro.ecom.cmu.edu/catalog.xsd”> <widget id=“1”> <name>Widget 1</name> <price currency=“USD”>10</price> </widget> <widget id=“2”>...</widget> ... </catalog> SOURCE: MICROSOFT
XML Data Schemas • XML for defining valid XML documents Contents of http://euro.ecom.cmu.edu/catalog.xsd: <ElementType name=“Name”> <String /> </ElementType> <ElementType name=“Price”> <String /> </ElementType> <ElementType name=“Widget”> <Element type=“#Name” minOccurs=“1” /> <Element type=“#Price” minOccurs=“1” /> </ElementType> SOURCE: MICROSOFT
ASP / DOM (xmldom.asp) HTML HTML XML Document (transform.xml) XSL StyleSheet (transform.xsl) ASP / DOM (xmldom.asp) XML Data Transformation XSL Stylesheet (render2.xsl) XML Document (adors.xml) XSL Stylesheet (render1.xsl) SOURCE: MICROSOFT
XSD (XML Schema Definition) • XSD describes the structure of data • Defines the allowed tags and attributes • XSD is an XML language that : • defines elements that can appear in a document • defines attributes that can appear in an element • defines hierarchy and number of child elements • defines data types for elements and attributes • defines default and fixed values for elements and attributes
Root tag = schema Namespace for this file Namespace being defined Local elements must specify a namespace Begin definition of element “textbook” subelements must occur in sequence “textbook” has subelements string element “author” string element “title” date element “publishdate” string element “ISBN” element “price” “price” must be an integer > 0 but not > 100 An XSD File <?xml version="1.0"?> <!-- XML Schema Example for eCommerce Technology --> <xs:schema xmlns:xs="http://www.cmu.edu/XMLschema" targetNamespace="http://www.cmu.edu" xmlns="http://www.cmu.edu" elementFormDefault="qualified"> <xs:element name="textbook"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="author" type="xs:string"/> <xs:element name="ISBN" type="xs:string"/> <xs:element name="publishdate" type="xs:date"/> <xs:element name="price"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minExclusive value="0"/> <xs:maxInclusive value="100"/> </xs:restriction> </xs:simpleType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
XSL (Extensible Stylesheet Language) • XSL describes presentation of data • Three parts of XSL: • XSLT (language for transforming XML documents) • XPath (language for extracting parts of an XML document) • XSL Formatting Objects (vocabulary for formatting XML documents)
LOOK FOR ALL “TITLE” TAGS PUT THE CONTENTS OF “TITLE” TAGS INTO RED HEADER FONT ARIAL DO THE SAME FOR THE CHILDREN OF “TITLE” TAGS XSL Extensible Style Language REWRITING RULES FOR MAPPING XML TAG CONTENTS TO HTML <xsl> <rule> <target-element type="title"/> <H1 color="red" font-family="Arial"> <children/> </H1> </rule> </xsl> SOURCE: WDVL.COM
XML Style SheetProcessor HTML Page XSL Style Sheet XML Style Sheet Processing SOURCE: SOFTWARE AG
XSL StyleSheet Parser <?xml?> <weather-report> <date>September 10, 1999</date> <time>08:00 </time> <area> <city>Darmstadt</city> <temperature scale=“C”>25</temperature> HTMLPage Style Sheet Processor Application Document Tree XSL as Part of an XML Application Schema SOURCE: SOFTWARE AG
XSL Functions • Transform XML into any other language or format • Filter and sort XML data • Extract parts of an XML document • Format XML data based on the data value (like displaying negative numbers in red) • Output XML data to different devices, like screen, paper or voice (SpeechML) SOURCE: CAMUS
XPath Expressions • //order[3]/item[2] • (2nd “item” tag in 3rd “order” tag) • //purchase/item[id=508] • (Inside a “purchase” tag, any “item” tag with “id” subelement having value 508) • //payment[payment_header/@date="1999-02-04"][currency="CAD"] • (Any payment in Canadian dollars made on April 4, 1999) SOURCE: CAMUS
Print Transform Print Production Editing & Update Data Capture Data Management Product Staging Data Creation Web Server Web Transform Product Repository Master Repository Wireless Delivery Wireless Transform Data Interchange Interchange Transform Multiple Data Uses with XML • Data created once can be delivered in different formats XML SOURCE: OASIS
Company A Company B Data Access / Update Data Access / Update Data Management Data Management Internet Import / Export Transform Messaging Messaging Import / Export Transform System B System A External Integration with XML SOURCE: OASIS
Docu-ment DTD Parser startDocument Application implementsDocumentHandler startElement startElement endElement DOM SAX endElement endDocument Using XML – SAX and DOM SAX = Simple API for XML DOM = Document Object Model Document Tree SOURCE: SOFTWARE AG 1
DOM Methods for Navigation parentNode previousSibling nextSibling firstChild lastChild childNodes(length, item()) getElementsByTagName SOURCE: SOFTWARE AG
XMLServer 1 2 3 4 5 6 Financial Reporting Example Documents have many customers Creation Quality &Assurance Distribution Consumption Reporting Enterprise Banks StockExchanges Financial Auditor Tax Advisor Government Media, Press & Financial Portals Analysts SOURCE: SOFTWARE AG
Ubiquitous XML Architecture SOURCE: PROF. JEROME YEN
Software AG EntireX Orchestrator CRM ERP Legacy Database Middleware Web Applications WebSphere WebLogic BroadVision Siebel Vantive Clarify SAP PoeopleSoft JDEdwards Oracle CICS, IMS, 3270, 5250 COBOL Natural VSAM File, Program DB2, Oracle Sybase Informix SQL Server Adabas MQSeries Socket COM* CORBA* Adapter Adapter Adapter Adapter Adapter Adapter Transformation Integration Repository Routing Management Rules * via EntireX Communicator SOURCE: SOFTWARE AG
Automotive Industry VCard Open Financial Exchange (OFX) Telecomms Webbroker Legal Working Group Chemical Markup Language Web IDL (WIDL) Classified Ads Open Trading Protocol (OTP) Workflow Industry XML Schemas • Many XML schemas have been defined for specific tasks or marketplaces SOURCE: MICROSOFT
Financial XML “Implementations” • (Financial Products Markup Language) • FIXML (FInancial eXchange ML) • (FINancial XML) • FSML (Financial Services ML) • (Straight-Through Processing ML) • (SWIFT ML)
eBusiness XML • ebXML (eBusiness XML) • eCX (eCatalog XML) • Tracker XML (for import/export) • tXML (Transportation XML, for logistics) • (VISA XML Invoice Specification) • (eXtensible Business Reporting Language)
Scientific XML • CML (Chemical ML) • GEML (Gene Expression Markup Language) • MathML (Mathematics ML) • RoboML (Robotics ML)
Impact of XML • Interchange mechanism between applications • Rapidly becoming the database language of the Web • XML client/server/server transactions over http: • Permits web data repositories • XML properties: • Scalable • Maintainable • Easy to use (spreadsheet style skills) • Interoperable (exchange business components)
Standard Encodings • Business systems must exchange data in different formats: • Invoices, payment orders, checks, bills of lading, delivery instructions, authentication information • Need standard notation to describe transmitted data in communication protocols • BUT: what do the bits inside the tags mean? • What does 437573746F6D6572 (hex) mean? • Where do fields begin and end? • How about complex data structures (arrays, etc,)?
Abstract Syntax Notation (ASN) • ASN.1 is a method of encoding data so that the format can be decoded from the data itself • ASN.1 is not a programming language • It describes only data structures. No code, no logic.
Abstract Syntax Notation • ASN.1 has primitive types:BOOLEAN, INTEGER, REAL, ENUMERATED, BIT STRING, IA5STRING, . . . • ASN.1 has • SET (unordered) SEQUENCE (fixed order) of primitive types • CHOICE for selecting alternative types (integer or real) • Can define new types: Month ::= INTEGER (1..12)Day ::= INTEGER (1..31)Daily-stock-volume ::= SEQUENCE SIZE (31) OF INTEGER
Basic Encoding Rules (BER) • Define how fields described in ASN.1 should be encoded • Units of BER are data elements • A data element is a triple: { identifier-type, length, value } • Some type codes: • The string “Customer” would be encoded as 16 08 43 75 73 74 6F 6D 65 72 BOOLEAN 01 IA5STRING 16 (8-BIT ASCII) INTEGER 02 SEQUENCE 10 SET 31 HEX “r” IA5STRING LENGTH8 HEX “C” HEX “u”
Basic Encoding Rules • Content field may be primitive (value) or structured (content has subcomponents)
Basic Encoding Rules BBCard ::= SEQUENCE { name IA5String (SIZE (1..60)), team IA5String (SIZE (1..60)), age INTEGER (1..100), position IA5String (SIZE (1..60)), handedness ENUMERATED {left-handed(0), right-handed(1), ambidextrous(2)}, batting-average REAL } “Casey”, “Mudville Nine”, 32, “left field”, ambidextrous, 0.250 (47 bytes of text) C a s e y M u d v i l l e302D1605 43617365 79160D4D 75647669 6C6C6520 4E696E65 02012016 0A6C6566 74206669 656C640A 01020903 80FE01 (47 bytes in BER)
SOURCE LANGUAGE (JAVA, C) DATA STRUCTURES APPLICATION CODE ASN.1 DEFINITIONS APPLICATION PROGRAM ENCODER/ DECODER Using ASN.1/BER ASN.1 COMPILER APPLICATION PROGRAM (JAVA, C) COMPILER APPLICATION PROGRAM NOW READS AND WRITES DATA ACCORDING TO BER
ASN.1 Applications • Telephone billing information • Transferred Account Procedure (TAP3) • UMTS (3G phones) • X9 financial services (checks, electronic funds transfer) • Air-to-ground aircraft information • Electric and gas utilities • Automobile diagnostic monitoring systems • Radio Frequency Identification (RFID) • Biometric IDs (Proposed ANSI Standard X9.84) • Common Biometric Exchange File Format CBEFF • Smart cards (ISO 7816-4) • MORE
Standards using ASN.1 • X.400 Message Handling System / X.500 Directory Services • LDAP based Directories / X.509 Digital Certificates • RSA Public Key Cryptography Standards • Storage and Transmission of Keys / Certificates (PKCS #12) • Secure Electronic Transaction (SET) • Visa / Mastercard • H.323 / T.120 Multimedia Communication Standards • Definition and Exchange of Multimedia Terminal Capabilities • Telecommunications Management Network (TMN) • Performance / Fault and Configuration Management Information • Unicode Worldwide Character Standard • Universal 16-bit Character Set comprising all written languages • Simple Network Transfer Protocol (SNMP) • Management Information Base (MIB) / SNMP PDUs
XML and ASN.1 • Both XML and ASN.1 represent hierarchical (tree-structured) data • Therefore, one can be translated into the other! • IBM ASN.1/XML translator • We also have XER, the XML encoding rules