1 / 30

Comparing HTML, XML, and XHTML

Comparing HTML, XML, and XHTML. Ellen Pearlman Eileen Mullin Programming the Web Using XML. Learning Objectives. Trace the effect that the Web's immediate popularity had on the development of HTML, XML, and XHTML

lazaro
Download Presentation

Comparing HTML, XML, and XHTML

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. Comparing HTML, XML, and XHTML Ellen Pearlman Eileen Mullin Programming the Web Using XML

  2. Learning Objectives • Trace the effect that the Web's immediate popularity had on the development of HTML, XML, and XHTML • Learn about the XML compatibility requirements that differentiate an XHTML document from earlier HTML ones • Discover how namespaces are used by XML and XHTML documents • Learn about how XML manages documents and data

  3. Hypertext and Hyperlinking • The concept of hypertext – electronic linking between documents stored on computer systems – has been around nearly as long as computer systems themselves. • A graphic or text link on a Web page that opens another Web page or document is known as a hyperlink, and the act of following a link to the intended destination is called hyperlinking.

  4. The Origins of HTML • HTML was originally created by Tim Berners-Lee, a physics researcher at the European Center for Nuclear Research (CERN). • Berners-Lee built a program to allow these documents to be viewed and hyperlinked to each other; programs like this are now known as Web browsers.

  5. Web Protocols • Berners-Lee also designed a set of instructions (called a protocol) to tell a browser what Web document to retrieve, how to obtain it and how to display it. • This protocol is calledhttp(for HyperText Transfer Protocol) and constitutes the beginning part of most Web addresses (or URL, short for Universalor Uniform Resource Locator).

  6. Web Pages • HTML documents are also commonly called Web pages. The main entry point on an individual or organization’s Web site is called the home page, and usually takes as its filename index.html or index.htm. • These file extensions (.html and .htm) tell the Web browser that the file should be viewed as a Web page using a Web browser, in the same way that a file ending with .doc is an indicator that the file is a word processing document that should be opened with Microsoft Word.

  7. The Limitations of HTML • As the Web rapidly gained in popularity, HTML quickly proved inadequate to play host to multimedia, games, and animation, and forms processing. • A committee of dedicated researchers convened the World Wide Web Consortium (W3C) to develop future incarnations of the language.

  8. The Limitations of HTML (2) • To accommodate continued user demands for typographic and presentation controls, the Cascading Style Sheets (CSS) standard was introduced. • However, the W3C concluded that what Web developers truly needed was a meta-language – a language for writing new Web languages. This effort was what led to the creation of XML.

  9. The Emergence of XML • The W3C decided to develop a streamlined version of SGML to serve the purpose of linking many kinds of computer languages together with a single tagging system. • Named the Extensible Markup Language (XML), it was designed to parallel HTML but would let developers create and specify new tags, structures, attributes, and other Web language elements.

  10. HTML <html> <head> <title>Memo</title> </head> <body> <h2>To: Dorm Residents</h2> <h2>From: Resident Advisor</h2> <h2>Date: 11-17-03</h2> <h2>Subject: Fire Hazards</h2> <br> <p>Boxes should not be stored in hallways, stairwells, or against doors. These areas must be clear at all times.</p> </body> </html> XML <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE correspondence SYSTEM "Memo_template.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <filename>111703 Memo</filename> <title>Memo</title> <to>Dorm Residents</to> <from>Resident Advisor</from> <date>11-17-03</date> <subjectFire Hazards</subject> <message>Boxes should not be stored in hallways, stairwells, or against doors. These areas must be clear at all times.</message> Comparing HTML to XML

  11. Comparing HTML to XML (2) • Although HTML can display your data it really doesn’t indicate what the information means or how to use it. • XML, on the other hand, is a markup language that classifies the data it contains. • One caveat is that XML is much stricter than HTML about how well you code your markup.

  12. XML Technologies • XML spurred development of a number of robust technologies, including: • Extensible Stylesheet Language (XSL) • XML Schema • Xpath • When the W3C decided to reformulate HTML based on XML rather than previous versions of HTML, it led to the renaming of HTML as Extensible Hypertext Markup Language (XHTML).

  13. Taking the Mid-Road with XHTML • XHTML was first released in early 2000 to meet the needs of XML within Web pages. It lets you create sets of markup tags for new purposes. Its benefits include: • Separating presentation markup from content. • You can use XML tools and technologies with your XHTML documents. • XHTML 1.1 is modular: The parts of an XHTML document can be divided into separate modules and added or removed.

  14. XML’s Compatibility Requirements • As an XML-based language, XHTML has strict rules regarding its syntax. • If you make mistakes in creating HTML code, most Web browsers will strive to display the page as best as possible anyway. • Your page will not display at all within an XML-enabled browser if the XHTML syntax is flawed. • Luckily, the syntax and coding rules of XHTML are very easy to learn, and are truly not that different from those of HTML.

  15. A Sample XHTML Document

  16. Creating an XHTML Document • The tags that are needed in an XHTML document describe: • XML declaration, for indicating to the Web browser what version of XML is at work here. • DOCTYPE declaration, which appears only in a document that uses a document type declaration (DTD). • XML namespace

  17. XML Declarations • All XML and XHTML documents begin with an XML declaration that signals to XML-compliant tools like editors and browsers that they can process this document. <?xml version="1.0" encoding="UTF-8"?> • XML supports the Unicode character set, which provides multilingual capabilities in your XHTML or XML documents. UTF-8 is one method of encoding Unicode characters.

  18. DOCTYPE Declaration and Document Type Definition (DTD) • The DOCTYPE declaration immediately follows the XML declaration: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> • The most recent version of XHTML, called XHTML 1.1, uses a single XML document type, which too is called XHTML 1.1. • XHTML 1.0 uses three XML document types that correspond to three DTDs: Strict, Transitional (the one you’ll most likely use), and Frameset.

  19. XML Namespaces • An XML namespace lets you distinguish which definition you mean when you use certain tags. <html xmlns="http://www.w3.org/1999/xhtml"> • For example, the tags <title> or <table> could either be used in their HTML sense or when tagging a listing of library records or furniture inventory. • Specifying an XML namespace is the way to avoid any confusion about what is meant by each tag name.

  20. Reformulating an HTML Document into HTML • Add an XML declaration • Add a DOCTYPE declaration to point to an XHTML DTD • Specify the XML namespace • Clean up the HTML: Ensure tags are nested, lowercase tags are used, closing tags and empty elements are specified. • In XHTML, quotes are required on attributes.

  21. XHTML Is Only Part of What You Can Do on the Web With XML

  22. Choosing to Use XHTML or XML • XHTML does not extend to you the full potential of XML. XHTML represents just one vocabulary of XML. • XML has the ability to dynamically describe the data that it transmits. Other languages and tools are then needed to display and reformat an XML document on the Web, or to share its data with other applications.

  23. XHTML vs. XML: Choosing the Right Language for the Job • Use XHTML • when you’re creating a display-only or brochure-type Web site • when you want to quickly publish your documents on the Web • when you’re redesigning a large set of existing static HTML pages

  24. XHTML vs. XML: Choosing the Right Language for the Job (2) • Use XML • to dynamically generate your content’s presentation with different layouts and forms. • to store your documents and data in a format that’s searchable, reusable, and cross-platform. • when you want your data to be able to interact with applications. • when you’re pursuing a “knowledge management” strategy to make your organization’s information accessible on demand

  25. Going Further with Namespaces <?xml version="1.0" encoding="UTF-8"?> <furn:furnishings xmlns:furn="http://genuineclass.com/xml/homefurnishings/" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <xhtml:table> <xhtml:tr> <xhtml:td><furn:table material="walnut" type="dining"/></xhtml: td> <xhtml:td><furn:chair material="beech" type="dining"/></xhtml:td> <xhtml:td><furn:lamp material="iron" type="floor"/></xhtml:td> </xhtml:tr> </xhtml:table> </furn:furnishings>

  26. Using a Default Namespace <?xml version="1.0" encoding="UTF-8"?> <furnishings xmlns="http://genuineclass.com/xml/homefurnishings/" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <xhtml:table> <xhtml:tr> <xhtml:td><table material="walnut" type="dining"/></xhtml:td> <xhtml:td><chair material="beech" type="dining"/></xhtml:td> <xhtml:td><lamp material="iron" type="floor"/></xhtml:td> </xhtml:tr> </xhtml:table> </furnishings>

  27. Purposes of XHTML and XML • There are really two purposes for XHTML and XML: managing documents and data. • In many cases, XHTML will be sufficiently for publishing static, brochure-type documents on the Web. • Data applications, on the other hand, can include a much wider assortment of uses, and require XML’s flexibility.

  28. Data and Metadata • One of the biggest problems the future may hold for the Web is growth. • One of the technologies currently in development by the W3C to address this is an XML vocabulary called the Resource Description Framework (RDF). • RDF is an XML-based language for expressing metadata, which is data about data.

  29. Summary • Using XHTML is only the tip of the iceberg that comprises the XML syntax. • Using XHTML is a means of readying your Web pages for the next generation of Web browsers. • Making your data available to other applications will require you to work with XML, rather than just XHTML.

  30. The End

More Related