1 / 134

XML (eXtensible Markup Language)

XML (eXtensible Markup Language). Prepared for: *Stars* New Horizons Certified Professional Course. Session Objective. What is a Markup Language ? What is XML ? HTML and XML Why do we need XML ? What is XML Used For ? Is XML just for Programmers ? XML & Its Features

Download Presentation

XML (eXtensible Markup Language)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. XML(eXtensible Markup Language) Prepared for: *Stars* New Horizons Certified Professional Course

  2. Session Objective • What is a Markup Language ? • What is XML ? • HTML and XML • Why do we need XML ? • What is XML Used For ? • Is XML just for Programmers ? • XML & Its Features • XML is Case Sensitivity • XML Processors • XML-Related Technologies • XML Evolution • XML building blocks

  3. Session Objective (cont…) • The General Structure of XML • Structure of an XML Document • XML Tags • Elements and sub elements • XML Attributes • Elements and attributes • XML documents • XML as a Tree • Anatomy of an XML Document • XML Terminology • Well formed XML documents • Well formed XML

  4. Session Objective (cont…) • Entities • Comments • Names in XML • Namespaces • Namespaces and URIs • Namespace syntax • Valid XML documents • XML: The DTD • XML Syntax Rules • Presenting XML documents • Viewing XML • Viewing XML Files

  5. Session Objective (cont…) • Displaying XML with CSS • Displaying XML with XSLT • XML Parser • The XML DOM • XML to HTML • XML Application • Working with XmlReader & XmlWriter • Overview of XmlReader • Reading an XML File • Overview of XmlWriter • Writing an XML File • Extended document standards • Vocabulary

  6. What is a Markup Language? • A markuprefers to the use of characters within a piece of information that can be used to process or identify that information in a particular way. • Example :- The following Example uses greater-than and less-than symbols to identify markup elements, or tags, that have specific purposes. <HTML> <HEAD> <TITLE>Title Page</TITLE> </HEAD> <BODY> <H1>This is text using a heading tag</H1> This is normal text. </BODY> </HTML>

  7. What is a Markup Language? • If the above HTML document were viewed in a browser, the browser would interpret the markup elements and display the content to reflect the author’s intentions. • For example, the <H1> and </H1> tags are used to display the text in a large font, whereas the text immediately following it is displayed in the browser’s standard font. • There are a number of different markup languages and types. Lets review three of the most common – SGML, HTML, XML.

  8. What is XML? • XML is an acronym for eXtensible Markup Language. • XML was designed to transport and store data. • XML stands for eXtensible Markup Language • XML is a markup language much like HTML • XML was designed to carry data, not to display data • XML tags are not predefined. We must define your own tags • XML is designed to be self-descriptive • XML is a W3C Recommendation • Like its predecessor HTML, it has its root in a standard known as the Standard Generalized Markup Language, or SGML. • To understand why we need XML, let’s take a look at both SGML and HTML.

  9. What is XML ? (cont…) • Simpler SGML • XML is a meta-language. • A meta-language is a language that's used to define other languages. • We can use XML for instance to define a language like WML. • XML is a smaller version of SGML. • It's easy to master and that's a major advantage compared to SGML which is a very complex meta-language.

  10. What is XML ? (cont…) SGML • Standard Generalized Markup Language (SGML) was designed as a standard way to store data independent of any software application or platform. • SGML is often referred to as a meta language. Meta languages are languages that are used for describing markup languages. HTML is a derivative of SGML and is therefore called an SGML application. • There are a number of languages based on SGML. There are also a number of standard Data formats based on SGML. • The real power behind SGML is its ability to declare Document Type Definitions, or DTD’s.

  11. What is XML ? (cont…) SGML • SGML provides the ability to define the contents of the document, its markup characteristics, and its information model. • The downside to SGML is that it is all encompassing, and has a lot of rules. It has so many aspects to it that it is almost impossible to implement all of them. • For this reason, SGML is rarely used by itself. Instead, subsets have been created that target niche applications and needs.

  12. What is XML ? (cont…) HTML • Hyper Text Markup Language (HTML) is the first internationally accepted derivative of SGML. • HTML is really the document language of the World Wide Web. • HTML was originally designed to represent document based data within a browser in very basic form. • It has evolved over time to support application features through the use of JavaScript, Java Applets, and the inclusion of client-side plug-ins.

  13. What is XML ? (cont…) HTML • It is not a good language for applications to store and share data. One of the primary reasons for this is its lack of support for DTD’s. • DTD’s are external elements that define the contents and structure of the data. • HTML’s structure is extremely limited compared to its predecessor SGML. • HTML was designed as a document language, not a data language. This is where XML enters the picture.

  14. What is XML? (cont…) • XML: What it can do • With XML we can : • Define data structures • Make these structures platform independent • Process XML defined data automatically • Define our own tags • With XML we cannot : • Define how our data is shown. To show data, we need other techniques.

  15. What is XML? (cont…) XML Does not DO Anything • Maybe it is a little hard to understand, but XML does not DO anything. • XML was created to structure, store, and transport information. • The following example is a note to Tove from Jani, stored as XML: <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>

  16. What is XML? (cont…) • The note above is quite self descriptive. • It has sender and receiver information, it also has a heading and a message body. • But still, this XML document does not DO anything. • It is just pure information wrapped in tags. • Someone must write a piece of software to send, receive or display it.

  17. What is XML? (cont…) XML is Just Plain Text • XML is nothing special. It is just plain text. • Software that can handle plain text can also handle XML. • However, XML-aware applications can handle the XML tags specially. • The functional meaning of the tags depends on the nature of the application.

  18. What is XML? (cont…) With XML You Invent Your Own Tags • The tags in the example above (like <to> and <from>) are not defined in any XML standard. These tags are "invented" by the author of the XML document. • That is because the XML language has no predefined tags. • The tags used in HTML (and the structure of HTML) are predefined. HTML documents can only use tags defined in the HTML standard (like <p>, <h1>, etc.). • XML allows the author to define his own tags and his own document structure.

  19. What is XML? (cont…) XML is Not a Replacement for HTML • XML is a complement to HTML. • It is important to understand that XML is not a replacement for HTML. • In most web applications, XML is used to transport data, while HTML is used to format and display the data. • XML is a software and hardware independent tool for carrying information.

  20. What is XML? (cont…) XML is Everywhere • It has been amazing to see how quickly the XML standard has developed, and how quickly a large number of software vendors have adopted the standard. • XML is now as important for the Web as HTML was to the foundation of the Web. • XML is everywhere. • It is the most common tool for data transmissions between all sorts of applications. • It is becoming more and more popular in the area of storing and describing information.

  21. HTML and XML XML stands for eXtensible Markup Language HTML is used to mark up text so it can be displayed to users XML is used to mark up data so it can be processed by computers HTML describes both structure (e.g. <p>, <h2>, <em>) and appearance (e.g. <br>, <font>, <i>) XML describes only content, or “meaning” In XML, you make up your own tags HTML uses a fixed, unchangeable set of tags

  22. HTML and XML (cont…) • HTML and XML look similar, because they are both SGML languages (SGML = Standard Generalized Markup Language) • Both HTML and XML use elements enclosed in tags (e.g. <body>This is an element</body>) • Both use tag attributes (e.g.,<font face="Verdana" size="+1" color="red">) • Both use entities (&lt;, &gt;, &amp;, &quot;, &apos;) • More precisely, • HTML is defined in SGML • XML is a (very small) subset of SGML

  23. HTML and XML (cont…) • HTML is for humans • HTML describes web pages • You don’t want to see error messages about the web pages you visit • Browsers ignore and/or correct as many HTML errors as they can, so HTML is often sloppy • XML is for computers • XML describes data • The rules are strict and errors are not allowed • In this way, XML is like a programming language • Current versions of most browsers can display XML • However, browser support of XML is spotty at best

  24. Why do we need XML? • Data-exchange - XML is used to aid the exchange of data. It makes it possible to define data in a clear way. - Both the sending and the receiving party will use XML to understand the kind of data that's been sent. - By using XML everybody knows that the same interpretation of the data is used.

  25. Why do we need XML? (cont…) • Replacement for EDI - EDI (Electronic Data Interchange) has been for several years the way to exchange data between businesses. - EDI is expensive, it uses a dedicated communication infrastructure. - XML is a good replacement for EDI. It uses the Internet for the data exchange. And it's very flexible.

  26. Why do we need XML?(cont…) • More possibilities - XML makes communication easy. It's a great tool for transactions between businesses. - We can define other languages with XML. • A good example is WML (Wireless Markup Language), the language used in WAP-communications. - WML is just an XML dialect.

  27. What is XML Used For? • XML has created a quite revolution on the Internet. • It is the first truly portable data format that was designed for Internet and multi-language support. • The number of applications for XML are limitless. • Here are just a few of the areas that XML has gained momentum. • Business to Business E-Commerce • This is one of the areas that XML has moved most rapidly. Getting businesses to talk the same data “language” has always been difficult. • Differences in software and hardware platforms have always been big issues for companies that want to communicate electronically.

  28. What is XML Used For? XML Vs. EDI (Electronic Data Interchange) • Differences in data representation between organizations was another major hurdle. Having a standard for content modeling that could be interrogated by software was not part of the EDI model. • This required that the software that would use the EDI output would have to understand its content model inherently. Each company had one or more content models that it would create for different things (e.g. purchase orders, proposals, etc.) . Things got real complicated real fast. A good analogy is that of the telephone. • The problem with EDI was that each company that wanted to talk to each other had to reinvent the telephone for each type of discussion they wanted to have. Needless to say, EDI was not the panacea that many envisioned it to be.

  29. What is XML Used For? • XML addresses these issues in the way that it was designed. • It is platform independent, it is structured, and it has a mechanism for strict content modeling that can be interrogated by any software using a standard XML processor. • The result is that companies can communicate with each other using XML and engage in B2B E-Commerce without having to worry about hardware & software platform issues, or content modeling issues. • Many large organizations are now using XML for such things as requests for proposals, purchase orders and transaction records. • Since XML is designed for use with Internet protocols, the Internet has become the medium for transferring this XML data back and forth.

  30. What is XML Used For? (Cont...) • Catalogs • XML makes the perfect storage and transfer mechanism for information such as catalogs. This includes not only catalogs like those used for e-commerce, but also things like parts and inventory. • Companies can use XML to keep lists of information (catalogs) that can be shared and transferred between multiple departments, managers, outside vendors, etc.

  31. What is XML Used For? (Cont...) • Data Warehousing and Archiving • Storing large amounts of information for access by multiple applications is known as Data Warehousing. • XML can be used to store such information in usable chunks (documents) that can be retrieved from anywhere on the network or Internet, allowing users to get the information from anywhere. • Another use of XML is that of data archiving. A good example is the archiving of relational database data.

  32. What is XML Used For? (Contd...) • Data Migration • The problem however is that each system must understand the format of the data if they are going to be able to share such information. • XML is the perfect mechanism to be used for data migration. By storing application data in XML, other applications can interrogate and query such information using XML’s open standards. • Each application needs to know how to read one type of data storage, namely XML. This makes it much easier for application developers as they can use XML to export and import data.

  33. What is XML Used For? (Cont...) • XML Separates Data from HTML • XML Simplifies Data Sharing • XML Simplifies Data Transport • XML Simplifies Platform Changes • XML Makes Your Data More Available • XML is Used to Create New Internet Languages • If Developers Have Sense, future applications will exchange their data in XML.

  34. Is XML just for Programmers? • No. • XML is making its way into all kinds of Internet technologies, including HTML. • Microsoft is leading the way in incorporating XML into its browser. • Starting with Microsoft IE4.0, we can create XML data islands within our HTML that can be used to dynamically update data within the document instead of having to retrieve it from the server.

  35. Is XML just for Programmers? • It also incorporated XML support inside of the Document Object Model (DOM), making it easy to request XML documents from the server without having to constantly refresh our HTML pages. • It is expected that both Netscape Navigator and IE are going to increase their support for XML as new versions of their respective browsers become available.

  36. Is XML just for Programmers? (cont…) • Before long, XML will be as common to Web content providers and authors as HTML currently is. • Since XML is truly extensible, do not be surprised to see XML versions of HTML documents supported in the future. • XML is becoming the standard for all kinds of data storage.

  37. Is XML just for Programmers? (cont…) • New word processors and spreadsheets are outputting their data in XML, making it much easier to import and export data between platforms and applications. • XML is not just for programmers, even though most users will never directly interact with it. • It is a world wide standard that makes data storage and transfer much easier and reliable than ever before.

  38. XML & Its Features • XML incorporates many of the features of SGML, while learning from the limitations of HTML. • Like SGML, XML utilizes DTD’s, making it flexible and extensible. • The goals of XML were more focused than those of SGML, making it much easier to implement. These goals included:- • XML could be used with existing Internet protocols (HTTP, MIME, etc.). This makes it the ideal format for sharing information on the Internet.

  39. XML & Its Features • XML support is application independent. Any application can utilize and support XML documents. • XML is platform independent. Its use of technologies such as Unicode make it portable across machine types. • XML is license free. It is controlled by an international standards organization (ISO). This means that it isn’t going to cost you anything to use it. • XML is compatible with SGML.

  40. XML & Its Features (cont) • The feature set of XML was kept to a minimum so that applications could support it. Compare this goal with that of SGML. • XML is a family of technologies. XML has already evolved to include support for such things as style sheets, hyperlinks, and the Document Object Model (DOM). • XML takes the best of SGML (structured data definition capabilities) and the best of HTML (web addressing) .

  41. XML & Its Features (cont) • The result is a portable, highly usable, markup language that can be used by any number of applications to store and share structured data. • Applications that will benefit or are already benefiting from XML include: • Office applications (word processors, spreadsheets, etc.) • Web applications (browsers, e-mail, etc.) • Server applications (database servers, e-mail servers, etc.) • At its core, XML appears very simple. However, the implications of its use are very complex.

  42. XML is Case Sensitivity • XML is case sensitive, and this is a very important point for creating well-formed documents and for portability. • For example, the following will result in an error because the start tag <name> and the end tag </Name> are not recognized as the same. <name> <first>John</first> <last>Doe</last> </Name> • The above would result in an error regarding unmatched tags. • The following screen captures show how both XML-Notepad and IE5 react to the error.

  43. XML is Case Sensitivity Cont. • The reason that XML is case sensitive is very interesting. • Most ASCII based text systems will convert text into upper case so that case-sensitivity is not an issue. • However, XML is a portable standard, and by portable we mean language independent. • This is the very reason why XML supports Unicode, and not ASCII. • This makes it impossible to do any conversion with confidence since some character set conversions may behave differently than expected. • XML defaults to lower case. • It is recommended that we always use lower case as well.

  44. XML Processors • XML Processor is a piece of software, either an application or a library, that can process XML. • A good example of an XML processor is XML document validation software. • There are a number of such packages available for free and for sale on the Internet. Such applications can be used to validate the contents of an XML document and make sure that it is well-formed. • A well-formed document is one that adheres to the rules of XML and any associated DTD’s. • Other good examples include XML document viewers and XML document code libraries that can be used by software that you create to manipulate XML documents.

  45. XML-Related Technologies • DTD (Document Type Definition) and XML Schemas are used to define legal XML tags and their attributes for particular purposes • CSS (Cascading Style Sheets) describe how to display HTML or XML in a browser • XSLT (eXtensible Stylesheet LanguageTransformations) and XPath are used to translate from one form of XML to another • DOM (Document Object Model), SAX (Simple API for XML, and JAXP (Java API for XML Processing) are all APIs for XML parsing

  46. XML Evolution • XML is still evolving. • There are a number of derivatives and extensions to XML that are being used today. Some of these include: XSL / XSLT • eXtensible Style Sheets (XSL/XSLT) • XSL is a technology by which WE can embed XML within an HTML page and have the HTML processor (browser) populate the contents of the page using the embedded XML. • This is a very powerful technology, although not many browsers currently support it. • This is one of the most exciting XML implementations as it directly affects the way that data can be presented on the World Wide Web.

  47. XML building blocks • Aside from the directives, an XML document is built from: • elements: high in <high scale="F">103</high> • tags, in pairs: <high scale="F">103</high> • attributes: <high scale="F">103</high> • entities: <afternoon>Sunny &amp; hot</afternoon> • character data, which may be: • parsed (processed as XML)--this is the default • unparsed (all characters stand for themselves)

  48. The General Structure of XML • Define our own tags • In XML, we define our own tags. • If we need a tag <TUTORIAL> or <STOCKRATE>, that's no problem. • DTD or Schema • If we want to use a tag, we'll have to define it's meaning. • This definition is stored in a DTD (Document Type Definition). • We can define our own DTD or use an existing one. • Defining a DTD actually means defining a XML language. • An alternative for a DTD is Schema.

  49. The General Structure of XML (cont…) • Showing the results • Often it's not necessary to display the data in a XML document. • It's for instance possible to store the data in a database right away. • If we want to show the data, we can. • XML itself is not capable of doing so. • But XML documents can be made visible with the aid of a language that defines the presentation. • XSL (eXtensible Stylesheet Language) is created for this purpose. But the presentation can also be defined with CSS (Cascading Style Sheets).

  50. Structure of an XML Document Let’s get started by reviewing the structure of our example breaking this document down and see at how it really works. • The XML Declaration • The Root Element • The Logical Structure • Parents • Child • Siblings • XML and Databases • The Physical Structure • Synchronous Structures

More Related