Learning XML Basics Objectives In this session, you will learn to: ☛ Identify the limitations of EDI ☛ Identify the need for XML as a standard data interchange format ☛ Identify the differences between SGML, HTML, and XML ☛ Identify the role of World Wide Web Consortium (W3C) in defining XML-related specifications ☛ Create an XML document
©NIIT
eXtensible Markup Language/Lesson 1/Slide 1 of 40
Learning XML Basics What is Electronic Data Interchange ☛ EDI refers to the process of exchanging documents in a standard format between two computer systems. ☛ EDI is often used as a replacement for conventional business documents such as purchase orders, requests for quotations, invoices, and shipping notices.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 2 of 40
Learning XML Basics How Does EDI Work (Contd.) ☛ The sender of information uses computer files to assemble the data needed for a transaction. ☛ The assembled data is the input to a software module that transforms the transaction into the EDI standard format. ☛ The resulting data file generated by the software module is transmitted to the receiver via an intermediate channel company known as Value Added Network (VAN). ☛ This data file is treated as the input at the receiving end in which a software module translates the data from the EDI format into a file that can be understood by the receiver’s application system. ©NIIT
eXtensible Markup Language/Lesson 1/Slide 3 of 40
Learning XML Basics How Does EDI Work (Contd.) ☛ The above process includes a number of security procedures. Data security is maintained with the help of user identification numbers and passwords. ☛ The EDI standards also allow a receiver to send an acknowledgement message to the sender indicating successful receipt of information.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 4 of 40
Learning XML Basics EDI Standards ☛ Two standards of EDI are used widely. ☛ They are ANSI X12 and UN/EDIFACT. ☛ ANSI X12 is the most widely used EDI standard in the United States. ☛ The rest of the world uses the UN/EDIFACT standard. ☛ Many EDI software packages support both the standards.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 5 of 40
Learning XML Basics Hardware and Software Requirements for Implementing EDI ☛ For implementing EDI, you require EDI software and a modem (minimum 28.8k baud, 56k baud recommended). ☛ You need to convey transactions to and from your trading partners electronically. ☛ This can be done either using the point-to-point communication method or using a VAN as an intermediary between various trading partners. ☛ In the point-to-point communication method, you use a telephone line to dial your trading partner’s computer directly. ©NIIT
eXtensible Markup Language/Lesson 1/Slide 6 of 40
Learning XML Basics Benefits of EDI ☛ Reduction in data entry errors ☛ Elimination of communication lag time between an agency and a customer ☛ Improved customer service ☛ Minimized costs of transferring information ☛ Reduced order time
©NIIT
eXtensible Markup Language/Lesson 1/Slide 7 of 40
Learning XML Basics Limitations of EDI ☛ The limitations of EDI are as follows: ✓ Rigid Transaction Set ✓ Fixed Business Rules ✓ High Costs ✓ Slow Pace of Standards Evolution
©NIIT
eXtensible Markup Language/Lesson 1/Slide 8 of 40
Learning XML Basics Introduction to XML What is XML ☛ eXtensible Markup Language (XML) is a text-based markup language that enables you to store data in a structured format by using meaningful tags. ☛ The term "eXtensible" implies that you can extend your ability to describe a document by defining meaningful tags for your application. ☛ XML is a cross-platform, hardware, and software independent markup language. ☛ XML can be used to address the problems faced by EDI. ©NIIT
eXtensible Markup Language/Lesson 1/Slide 9 of 40
Learning XML Basics Introduction to XML Advantages of XML over EDI ☛ Some of the advantages of XML over EDI are listed below: ✓ Lower Cost ➤ XML
does not require a high priced VAN as in the case of EDI.
✓ Customized Business Rules ➤ XML
enables you to store data in a structured format by allowing you to create customized tags.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 10 of 40
Learning XML Basics Advantages of XML over EDI (Contd.) ☛ Easy to Interpret ✓ XML documents can be easily interpreted by the target systems by using a parser. ☛ Platform Independent ✓ As XML documents are platform independent, a business unit can have transactions with any other business unit irrespective of their data storage platform.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 11 of 40
Learning XML Basics Difference between SGML, HTML, and XML ☛ A markup language uses tags to indicate how a file should look when displayed on a Web page. ☛ Some examples of markup languages are Standard Generalized markup language (SGML) and Hypertext Markup Language (HTML). ☛ SGML allows documents to describe their own grammar by specifying the tag set used in the document and the structural relationship that these tags represent. ☛ SGML was complex and difficult for developers to master. ©NIIT
eXtensible Markup Language/Lesson 1/Slide 12 of 40
Learning XML Basics Difference between SGML, HTML, and XML (Contd.) ☛ HTML is based on SGML. ☛ In HTML, a user has to work with a set of predefined tags that is understood by the browser. ☛ XML is a subset of SGML. ☛ HTML is used for data presentation, whereas XML is used for data description and definition. Thus, the purpose of these two markup languages is completely different.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 13 of 40
Learning XML Basics Advantages of XML ☛ The advantages provided by XML are as follows: ✓ Domain Specific Vocabulary ✓ Data Interchange ✓ Smart Searches ✓ Granular Updates ✓ User-Selected View of Data
©NIIT
eXtensible Markup Language/Lesson 1/Slide 14 of 40
Learning XML Basics Introduction to World Wide Web Consortium ☛ W3C is responsible for the development of Web specifications (recommendations) that describe communication protocols and the technologies for the Web. ☛ Role of W3C in defining XML related specifications ✓ W3C has laid down certain rules that need to be followed by all XML applications. Listed below are some of these rules:
©NIIT
➤ XML
must be directly usable over the Internet.
➤ XML
must support a wide variety of applications.
➤ XML
must be compatible with SGML. eXtensible Markup Language/Lesson 1/Slide 15 of 40
Learning XML Basics Introduction to World Wide Web Consortium (Contd.) ➤ The
number of optional features in XML needs to be kept to the absolute minimum, ideally zero.
➤ XML
documents must be human-legible and clear.
➤ XML
©NIIT
design must be formal and concise.
eXtensible Markup Language/Lesson 1/Slide 16 of 40
Learning XML Basics Problem Statement 1.D.1 ☛ CyberShoppe requires a centralized repository of data about the products sold through its e-commerce site. It has three branches, which maintain data on their local computer systems. Data from all the three branches must be collated and housed in a centralized location. This data must be made available to the Accounts and Sales sections of these branches, regardless of the hardware and software platforms being used at the branches. The sales personnel also require access to the data using equipment, such as palmtops and cellular phones.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 17 of 40
Learning XML Basics Problem Statement 1.D.1 (Contd.) ☛ The product details of CyberShoppe consist of the name of the product, a brief description of the product, the price, and the available quantity on hand. Each product is uniquely identified by a product ID.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 18 of 40
Learning XML Basics Task List ☛ Identify the method to store data in a deviceindependent format. ☛ Identify the structure of the document in which data is to be stored. ☛ Create an XML document to store data. ☛ View the XML document in a browser.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 19 of 40
Learning XML Basics Task 1: Identify the method to store data in a device-independent format. Result ☛ XML provides a way to store structured data that is capable of being recognized by different kinds of devices. In other words, it enables deviceindependence.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 20 of 40
Learning XML Basics Task 2: Identify the structure of the document in which data is to be stored. ☛ Before you store data in an XML document, you need to organize it. ☛ An XML document is composed of a number of components that can be used for representing information. These components are: ✓ Processing Instruction ➤ An
XML document usually begins with the XML declaration statement or the Processing Instruction (PI).
➤ The
PI provides information regarding the way in which the XML file should be processed.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 21 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ➤ The
PI statement can be written as:
➤ In
the above example, the PI states that version 1.0 is used.
➤ The
PI uses the encoding property to specify information about the encoding scheme that is used to create the XML file.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 22 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ✓ Tag ➤ Tags
are used to specify a name for a given piece of information.
➤ Tags
usually occur in pairs.
➤ Each
pair consists of a start tag and an end tag.
➤
©NIIT
The start tag only contains the name of the tag while the end tag includes a forward slash (/) before the name of the tag.
eXtensible Markup Language/Lesson 1/Slide 23 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ✓ Elements ➤ Elements
are the basic units that are used to identify and describe data in XML.
➤ They
are the building blocks of an XML document.
➤ Elements
are represented using tags.
➤ An
XML document must always have a root element. All other elements are specified within the opening and closing tags of the root element.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 24 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ✓ Content ➤ The
information that is represented by the elements of an XML document is referred to as the content of that element.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 25 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ➤ An
element can contain any of the following:
➤ Character ➤
Elements can contain only textual information.
➤ Element
©NIIT
or Data Content
Content
➤
Elements can contain other elements.
➤
The elements contained in another element are called child elements.
➤
The containing element is called the parent element. eXtensible Markup Language/Lesson 1/Slide 26 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ➤ Element
Content
➤
A parent element can contain many child elements.
➤
All the child elements of a parent element are siblings and are thus related to one another.
➤ Combination ➤
©NIIT
Elements can contain textual information as well as other elements.
eXtensible Markup Language/Lesson 1/Slide 27 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ✓ Attributes ➤ Attributes
provide additional information about the elements for which they are declared.
➤ An
attribute consists of a name-value pair.
➤ Elements
can have one or more attributes. Attributes or attribute values can be either mandatory or optional.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 28 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ✓ Attributes ➤ While
deciding whether to represent information as an element or an attribute, you can follow the guidelines given below: ➤ If
the data must be displayed, you can represent it as an element. In general, element attributes are used for intangible, abstract properties such as ID.
➤ If
the data must be updated frequently, it is better represented as an element because it is easier to edit elements than attributes with XML editing tools.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 29 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ➤ If
the value of a piece of information must be checked frequently, it may be represented as an attribute.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 30 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ✓ Entities ➤ An
entity can be described as a short cut to a set of information.
➤ It
is a name that is associated with a block of data.
➤ This
data can be a chunk of text or a reference to an external file that contains textual or binary information.
➤ XML
supports the use of three kinds of entities: internal, general, and parameter entities.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 31 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ➤ Internal
Entities
➤ An
internal entity consists of a name that is associated with a block of information.
➤ This
can be identified easily as it is always preceded by an ampersand (&) symbol and terminated with a semicolon.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 32 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) ✓ Comments ➤ Comments
are statements that are used to explain the code.
➤ When
the code is executed, comment entries are ignored by the parser.
➤ Comments
©NIIT
are not essential in an XML file.
eXtensible Markup Language/Lesson 1/Slide 33 of 40
Learning XML Basics Task 2: Identify the structure… (Contd.) Result ☛ Structure of the XML document to be used for storing products data: PRODUCTDATA PRODUCT PRODUCTNAME DESCRIPTION PRICE QUANTITY ©NIIT
eXtensible Markup Language/Lesson 1/Slide 34 of 40
Learning XML Basics Task 3: Create an XML document to store data. ☛ Rules for Creating Well-formed XML Documents ✓ Every start tag must have an end tag. ✓ Empty tags must be closed using a forward slash (/). ✓ All attribute values must be given in double quotation marks. ✓ Tags must nest correctly. ✓ XML tags are case-sensitive. They must match each other in every implementation.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 35 of 40
Learning XML Basics Task 4:View the XML document in a browser.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 36 of 40
Learning XML Basics Problem Statement 1.P.1 ☛ The details of books sold by CyberShoppe need to be stored at a centralized location. This data needs to be made available to the various branches of CyberShoppe, regardless of the platforms used at various branches. The book details consist of the title of the book, the first and last names of the author of the book and the price of the book. Each book is uniquely identified by a book ID.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 37 of 40
Learning XML Basics Summary In this lesson you learned that, ☛ EDI is a standard format used for the exchange of business data among heterogeneous systems. ☛ XML is a text-based markup language that enables you to store data in a structured format using meaningful tags. ☛ XML is a method of storing data in a deviceindependent format. ☛ HTML and XML are subsets of SGML.
©NIIT
eXtensible Markup Language/Lesson 1/Slide 38 of 40
Learning XML Basics Summary (Contd.) ☛ An XML document consists of: ✓ Processing Instructions ✓ Elements ✓ Attributes ✓ Entities ✓ Comments ✓ Content
©NIIT
eXtensible Markup Language/Lesson 1/Slide 39 of 40
Learning XML Basics Summary (Contd.) ☛ The rules that govern the creation of a well-formed XML document are as follows: ✓ Every start tag must have an end tag. ✓ Empty tags must be closed using a forward slash (/). ✓ All attribute values must be given in double quotation marks. ✓ Tags must nest correctly. ✓ XML tags are case-sensitive. They must match each other in every implementation. ©NIIT
eXtensible Markup Language/Lesson 1/Slide 40 of 40