Using XML for Electronic Commerce
The HTML form shown in Figure 1 has been designed for input of an order for up to two different books using the Book Ordering Message. The values entered into the fields on the form are the values used in the example EDI message provided for the form in the EDItEUR EDI Implementation Guidelines for Book Trade Distribution.
Figure 1: HTML form for capturing EDItEUR Lite-EDI Book Order Messages
The eXtensible Markup Language (XML) is a subset of SGML specifically designed for easy delivery over the Internet. It requires that all non-empty elements of the document have both a start and an end-tag, that all attribute values be fully quoted and that no floating or otherwise ambiguous document structures be used.
Figure 2 shows how XML could be used to code a form whose appearance would be equivalent to the HTML form shown in Figure 1.
<!DOCTYPE Book-Order PUBLIC "-//EDItEUR//DTD Book Order Message//EN"> <Book-Order Supplier="4012345000094" Send-to="http://www.bic.org/order.in"> <title>EDItEUR Lite-EDI Book Ordering</title> <Order-No>967634</Order-No> <Message-Date>19961002</Message-Date> <Buyer-EAN>5412345000176</Buyer-EAN> <Order-Line Reference-No="0528837"> <ISBN>0316907235</ISBN> <Author-Title>Labaln, Brian/Chrome</Author-Title> <Quantity>2</Quantity> </Order-Line> <Order-Line Reference-No="0528838"> <ISBN>0856674427</ISBN> <Author-Title>Parry, Linda (ed)/William Morris</Author-Title> <Quantity>1</Quantity> </Order-Line> <input type="checkbox" name="partial" value="allowed"/> <text>Tick here if a delayed/partial supply of order is acceptable </text> <input type="checkbox" name="confirmation" value="requested"/> <text>Tick here if Confirmation of Acceptance of Order is to be returned by e-mail </text> <input type="checkbox" name="DeliveryNote" value="required"/> <text>Tick here if e-mail Delivery Note is required to confirm details of delivery </text> <E-Address>E-mail address: <input name="e-address" size="25"></input> </E-Address> <Language>Please respond in: <select name="response-language"> <option value="EN" selected>English</option> <option value="FR">Français</option> <option value="DE">Deutsch</option> <option value="ES">Espagnol</option> <option value="IT">Italiano</option></select></language> <input type="submit" value="Press here to send completed form to supplier"> </Book-Order>
Figure 2: XML encoding of Book Order Message
A typical reaction to seeing such a form is "Where has all the EDI information gone?". The answer is that all immutable information goes into the document type definition (DTD) referenced in the <!DOCTYPE
statement that starts the coding. Figure 3 shows the contents of this DTD. A single line reference to this DTD is sufficient to provide the browser with all the additional information it needs to process the message.
Note how the definition of each element defined in Figure 3 contains attributes whose fixed values contain the prefixes and suffixes of each of the EDIFACT fields that need to be generated in response to the messages.
The message format generated for the completed form could be a pure EDIFACT message of the type shown on Page II-2-2 of the EDItEUR EDI Implementation Guidelines for Book Trade Distribution.
<!DOCTYPE Book-Order [ <!--XML-conformant DTD for EDItEUR Book Order Message. Version 0.1 - Created 24-4-1997 by M. Bryan from The SGML Centre This DTD should be referenced using the following public identifier: PUBLIC "-//EDItEUR//DTD Book Order Message//EN" Corrected for minor errors 21-6-97 --> <!--Entities referenced within DTD--> <!--Support information elements are designed to supply information that can be used to control the processing of the message.--> <!ENTITY % support-info "(E-Address|Language|text|input|select)*" > <!--Entities used to datatype attribute values--> <!--Unique Resource Locator identifier. Contents of attribute must provide a valid HTTP or MAILTO address conforming to IETF RFC 822--> <!ENTITY % URL "CDATA" > <!--EAN location code. Number that uniquely identifies suppliers/purchasers. --> <!ENTITY % EAN "NUMBER"> <!--Formal EDIFACT definition of datatype. May be used by EDI-compliant browsers to validate the data entered by users prior to acceptance when a user attempts to move to another field. --> <!ENTITY % EDItype "NAME" > <!--Message Content element declarations--> <!--Book Order element: Purpose: Container for message fields and support information. Attributes: EDI-Prefix formally identifies type of message EDI-Suffix contains strings to be output at end of message Send-to identifies Unique Reference Locator (URL) for site to which EDIFACT message is to be sent for processing Supplier contains unique EAN that identifies supplier --> <!ELEMENT Book-Order (title?, Order-No, Message-Date, Buyer-EAN, Order-Line+, %support-info;) > <!ATTLIST Book-Order EDI-Prefix CDATA #FIXED "UNH+ME00579+ORDERS:D:93A:UN:EAN007" EDI-Suffix CDATA #FIXED "UNS+S'CNT+2:2'UNT+18+ME00579" Send-to %URL; #REQUIRED Supplier %EAN; #REQUIRED > <!--Title element: Purpose: Used to provide supplier dependent title for form: Title can be displayed in window header or at top of form, or in both locations: --> <!ELEMENT title (#PCDATA) > <!--Order Number element: Purpose: Allows users to assign unique number to their order. Attributes: EDI-Prefix formally indentifies type of message Datatype identifies format that contents must conform to Size indicates width of box to be used to capture input Title indicates text to precede box --> <!ELEMENT Order-No (#PCDATA) > <!ATTLIST Order-No EDI-Prefix CDATA #FIXED "BGM+220+" Datatype %EDItype; #FIXED "C8" Size NUMBER #FIXED "8" Title CDATA "Book Order No:" > <!--Message Date element: Purpose: To indicate date order was placed. Date must be entered in ISO 8601 format without separators, e.g. CCYYMMDD Attributes: EDI-Prefix formally identifies type of message EDI-Suffix identifies data to immediately follow contents Datatype identifies format that contents must conform to Size indicates width of box to be used to capture input Title indicates text to precede input field Comment contains explanatory text to follow the input field --> <!ELEMENT Message-Date (#PCDATA) > <!ATTLIST Message-Date EDI-Prefix CDATA #FIXED "DTM+137+" EDI-Suffix CDATA #FIXED ":102" Datatype %EDItype; #FIXED "Date" Size NUMBER #FIXED "12" Title CDATA "Message Date:" Comment CDATA "Enter dates in CCYYMMDD format" > <!--Buyer EAN identifier element: Purpose: To identify the unique EAN assigned to the purchaser. Attributes: EDI-Prefix formally identifies type of message EDI-Suffix identifies data to immediately follow contents Datatype identifies format that contents must conform to Size indicates width of box to be used to capture input Title indicates text to precede box --> <!ELEMENT Buyer-EAN (#PCDATA) > <!ATTLIST Buyer-EAN EDI-Prefix CDATA #FIXED "NAD+BY+" EDI-Suffix CDATA #FIXED "::9" Datatype %EDItype; #FIXED "C13" Size NUMBER #FIXED "13" Title CDATA "Buyer EAN:" > <!--Order line element: Purpose: Container for objects used to order book. Attributes: EDI-Prefix formally identifies type of message Line-no is calculated by system to be 1 + number of preceding order lines within file. Ref-Prefix identifies EDI prefix for reference number Reference-no uniquely identifies each line. Number is supplied by supplier's system with input file. --> <!ELEMENT Order-Line (ISBN, Author-Title, Quantity) > <!ATTLIST Order-Line EDI-Prefix CDATA #FIXED "LIN+" Line-no NUMBER #IMPLIED Ref-Prefix CDATA #FIXED "#RFF+LI:" Reference-No NUMBER #REQUIRED > <!--ISBN element: Purpose: To enter unique ISBN of book to be ordered Attributes: EDI-Prefix formally identifies type of message EDI-Suffix identifies data to immediately follow contents Datatype identifies format that contents must conform to Size indicates width of box to be used to capture input Title indicates text to precede box --> <!ELEMENT ISBN (#PCDATA) > <!ATTLIST ISBN EDI-Prefix CDATA #FIXED "PIA+5+" EDI-Suffix CDATA #FIXED ":IB" Datatype %EDItype; #FIXED "N12" Size NUMBER #FIXED "12" Title CDATA "ISBN:" > <!--Author and Title element: Purpose: Optional statement of author and title details to confirm correct ISBN has been entered. Attributes: EDI-Prefix formally identifies type of message Datatype identifies format that contents must conform to Size indicates width of box to be used to capture input Title indicates text to precede box --> <!ELEMENT Author-Title (#PCDATA) > <!ATTLIST Author-Title EDI-Prefix CDATA #FIXED "IMD+F+BST+:::" Datatype %EDItype; #FIXED "C60" Size NUMBER #FIXED "40" Title CDATA "Author/Title:" > <!--Quantity element: Purpose: To identify the number of copies required. Attributes: EDI-Prefix formally identifies type of message Datatype identifies format that contents must conform to Size indicates width of box to be used to capture input Title indicates text to precede box --> <!ELEMENT Quantity (#PCDATA) > <!ATTLIST Quantity EDI-Prefix CDATA #FIXED "PQTY+21:" Datatype %EDItype; #FIXED "N2" Size NUMBER #FIXED "2" Title CDATA "Quantity:" > <!--Declarations for message control support elements--> <!--Electronic Address element: Purpose: To capture electronic address to which messages from the supplier to the buyer can be sent. --> <!ELEMENT E-Address (#PCDATA|input)* > <!--Language element: Purpose: Container linking text to selection menu. --> <!ELEMENT Language (#PCDATA|select)* > <!--Text element: Purpose: Temporary element required becuase HTML input has no equivalent of the title element. --> <!ELEMENT text (#PCDATA) > <!--Input, select and option elements: Purpose: As per HTML (temporarily borrowed element). Attributes: As per HTML (temporarily borrowed attributes). --> <!ENTITY % InputType "(TEXT | PASSWORD | CHECKBOX | RADIO | SUBMIT | RESET | FILE | HIDDEN | IMAGE)" > <!ELEMENT input (#PCDATA) > <!ATTLIST input type %InputType; "TEXT" name CDATA #IMPLIED value CDATA #IMPLIED checked (checked) #IMPLIED size CDATA #IMPLIED maxlength NUMBER #IMPLIED src %URL; #IMPLIED align (top|middle|bottom|left|right) top > <!ELEMENT select (option+)> <!ATTLIST select name CDATA #REQUIRED multiple (multiple) #IMPLIED > <!ELEMENT option (#PCDATA) > <!ATTLIST option selected (selected) #IMPLIED value CDATA #IMPLIED > <!ENTITY % ISOlat1 PUBLIC "ISO 8879-1986//ENTITIES Added Latin 1//EN" > <!ENTITY % ISOnum PUBLIC "ISO 8879-1986//ENTITIES Numeric and Special Graphic//EN"> %ISOlat1; %ISOnum; ]>
Figure 3: XML Document Type Definition for Lite EDI Book Order