Platinum Edition Using Xhtml, Xml and Java 2by Eric Ladd, Andrew H. Watt, Mike Morgan, Jim O'Donnell
All the code and working applications developed in the book will be available for download from Que's web site at www.mcp.com/que
Completely updated and revised with the latest information about the newest web technologies including XHTML, Java 2 and XML.
- Pearson Education
- Publication date:
- Product dimensions:
- 7.79(w) x 9.44(h) x 2.47(d)
Read an Excerpt
Chapter 2: Introduction to XHTML
What Is XHTML?When XML was first released, you might have heard that it was going to "replace HTML." That was never really a possibility because XML is a meta-language, meaning it is a language used to create other markup languages. The real intent has always been to recast HTML according to the rules of XML. The World Wide Web Consortium (W3C) has completed this work and the result is the Extensible Hypertext Markup Language, or XHTML. XHTML 1.0 became a W3C Recommendation in January 2000 and it now falls to the Web community to embrace the new standard. For browser companies, this means reprogramming their browsers to work with XHTML code. For content developers, it means learning the ins and outs of the language.
By and large, XHTML is very much like HTML, so there are not a lot of new elements and attributes to learn. The biggest change for developers will be that all of XHTML's syntax rules must be followed or your document will not be rendered. This is vastly different from the way browsers work now. If you write an HTML document with syntax errors, most browsers will just gloss over them and render the document anyway. This kind of forgiving behavior will no longer be possible with XHTML.
This chapter introduces you to XHTML and what you must know to convert your existing HTML content to conform to the rules of XHTML. After a brief overview of XML and how it's related to XHTML, the chapter focuses on the major rules of XHTML and how you have to change your coding behavior to adhere to those rules.
N0TE: All the ideas covered in this chapter are pursued in greater depth in later chapters as well.Chapters 3 through 8 go into the specifics of the XHTML elements and their syntax. Chapters 10 through 17 delve into XML and how developers are using XML to create discipline specific markup languages.
What Is XML?The Extensible Markup Language, or XML, was developed to provide an alternative to the Standard Generalized Markup Language (SGML). Prior to XML, SGML was the only metalanguage available for developing other markup languages. SGML is a powerful language with features that enable you to develop markup languages for a wide variety of media. After you focus on the Web, however, you don't really need many of SGML's features that support markup for other types of publishing. This compelled the W3C to develop XML-a metalanguage that preserves the best features of SGML but filters out all the aspects of SGML that aren't necessary in a Web publishing environment.
When you develop a markup language with XML, you are creating an XML application. Even though XML is a relatively new meta-language, several XML applications are already in use. The Synchronized Multimedia Integration Language, or SMIL (pronounced "smile"), is an XML application used to orchestrate presentations for RealPlayer and other multimedia programs. Math Markup Language, or MM., is an XML application that facilitates the publishing of mathematical expressions on the Web. XML applications are also essential to custom business-to-business e-commerce applications.
XHTML is also an XML application. The HTML standard was originally written using SGML, but with XML on the scene, it became prudent to rewrite HTML as an XML application. The result of this effort is the XHTML 1.0 standard.
Where the Last HTML Standard Left OffThe most recent HTML standard-HTML 4.01-did a fine job of updating HTML to reflect contemporary use of the language. It also made great strides in supporting accessibility by introducing several elements and attributes that would allow users with different abilities to consume Web content. These include elements such as fieldset and legend for creating forms and the longdesc attribute for the img element.
However, HTML has been lacking the syntactic rigor present in other languages. This has been cultivated in large part by browsers that tolerate HTML syntax errors. After all, why should anyone correct his syntax errors if the documents look fine? While the major browsers have incorporated the capability to look beyond syntax errors, other browsers that rely on all syntax rules being followed have not. This means that people using these other browsers will often have their browsers "broken" by the abundance of erroneous HTML code that's out there.
HTML was also suffering from being extended to include a number of elements and attributes that are solely for presentation purposes and not for indicating the structure of the document. Traditional markup languages only specify structure and have no bearing on how the document looks onscreen. Instead, authors use style sheets to give the content a particular look and feel. In HTML, there was no separation between these two aspects of publishing, contrary to the spirit of how markup languages are implemented.
Applying the Rules of XML to HTMLTo help alleviate these problems, the W3C recast HTML as an XML application, resulting in the XHTML standard. XHTML addresses both of the previously noted problems with HTML. First and foremost, an XHTML document cannot be rendered if it is syntactically incorrect. This is a by-product of XML. One of the fundamental concepts in XML is that a document must be syntactically correct or valid to be rendered. Thus, if any XHTML document has just one syntax error, it is rejected.
Second, it puts Web authors on the path to using Cascading Style Sheets to indicate how content should look. In its strictest form, XHTML does not allow any of the elements that specify how content should look. Fortunately, the W3C has provided more permissive forms of XHTML for authors to work with initially. You should expect to transition to the strict form of XHTML eventually, however...
and post it to your social network
Most Helpful Customer Reviews
See all customer reviews >