An XHTML Primer
by Thomas Erl

The HTML specification, currently in its 4th revision, has been the preeminent markup language used for Web publishing over the past decade. Providing a fixed (non-extensible) set of markup tags, however, has been one of HTML’s primary limitations. Additionally, HTML coding rules are extremely flexible, allowing for the inconsistent authoring and design of Web pages. These two characteristics put HTML in sharp contrast to XML, which provides an extensible framework and enforces strict coding standards based on concepts of well-formedness and validity.

As owners of both the HTML and XML specifications, the World Wide Web Consortium (W3C) has decided not to continue developing HTML. Instead, the functionality of HTML will be provided through an implementation of XML in a new markup language called XHTML.

Besides providing a consistent and extensible platform for presentation-level code, one of the W3C’s primary objectives is to deliver user-interface portability, allowing Web pages to become device-independent. To accomplish this, a stripped down version of XHTML, called XHTML Basic, has been created and defined in a separate specification that achieved recommendation status last December.

To Web designers and authors, XHTML 1.0 will likely be looked upon as just another version of HTML, but to back-end developers, it provides a new framework for the manipulation of Web user-interfaces in alignment with XML.

XHTML 1.0 supports all of the tags defined in HTML 4.0, but the original DTDs used by HTML have been replaced with the following three XML DTDs:

<!DOCTYPE html PUBLIC “-//W3C XHTML 1.0 Strict//EN”
“DTD/xhtml1-strict.dtd”>

<!DOCTYPE html PUBLIC “-//W3C XHTML 1.0 Transitional//EN”
“DTD/xhtml1- transitional.dtd”>

<!DOCTYPE html PUBLIC “-//W3C XHTML 1.0 Frameset//EN”
“DTD/xhtml1- frameset.dtd”>

XHTML places a great deal of emphasis on the use of Cascading Style Sheets (CSS), and therefore supplies the Strict DTD which requires that all style attributes be placed in a separate CSS. The Transitional DTD permits the use of embedded style attributes for Web pages that need to support browsers which do not support CSS. The Frameset DTD is for the use of standard HTML frameset files.

Each of these DTDs impose a stricter adherence to well-formed coding rules. So strict, in fact, that use of any of these DTDs would invalidate 99% of the HTML content currently on the Web.

Web authors must place a reference to one of these DTDs at the beginning of every XHMTL document. Additionally, the HTML tag itself can contain a namespace reference allowing it to point to the standard W3C XHTML specification, or a customized extension.

The most significant changes Web authors will encounter when working with XHTML are syntactical. For instance, as with XML code, all XHTML body code must be lowercase, as follows:

Incorrect: < P ALIGN=”CENTER”>Life can be hell with XHTML</P>
Correct: < p align=”center”>Life can be swell with XHTML</p>

Additionally, element attributes must be enclosed with quotation marks, as follows:

Incorrect: <p align=center>Life can be hell with XHTML</p>
Correct: <p align=”center”>Life can be swell with XHTML</p>

In order to comply with the well-formedness rules, all XHTML tag constructs must be properly nested, as follows:

Incorrect: <p align=”center”><b>Life’s a beech with XHTML</p></b>
Correct: <p align=”center”><b>Life’s a peach with XHTML</b></p>

…and end-tags must always be supplied:

Incorrect: <p align=”center”><b>Life’s a beech with XHTML</p>
Correct: <p align=”center”><b>Life’s a peach with XHTML</b></p>

Finally, one of the major changes to traditional HTML coding requires that all standalone tags (elements that do not require end-tags) be modified with a termination character, as follows:

Incorrect: <img src=”sadface.jpg”><br>
Correct: <img src=”happyface.jpg” /><br />

A complete XHTML-compliant document would appear as follows:

<!DOCTYPE html PUBLIC “-//W3C XHTML 1.0
Transitional//EN” “DTD/xhtml1- transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
  <title>My Poem</title>
</head>
<body>
   <p align=”center”>
       Life can be swell,<br />
       with <b>XHTML</b>.
   </p>
   <img src=”happyface.jpg” />
</body>
</html>

The above samples illustrate only some of the coding rules enforced by XHTML. The slightest violation of these rules will result in a validation error, preventing the Web page from being displayed. In addition to the obvious benefits of having all Web page syntax consistently coded and structured, this framework requires XHTML parsing engines to do less work than traditional HTML parsers (which were designed to compensate for inconsistent HTML coding), and as a result reduces the footprint and processing requirements for Web pages and user interfaces. This opens up the use of XHTML (through the XHTML Basic subset) to mobile and other non-browser devices with more restrictive system requirements (hence achieving the W3C’s objective of providing portability).

Also worth mentioning is the emergence of the XHTML 1.1 specification, which trims the presentation tag feature set even more by dropping support for previously deprecated elements and attributes, again placing more emphasis on the use of CSS. Finally, an XML Events specification is being developed (currently a W3C working draft), which promises to integrate XHTML behaviours with DOM event interfaces. (A “basic” version of the XML Events specification is also being drafted.)

Even though the XHTML 1.0 specification achieved W3C recommendation status over a year ago, industry adoption of XHTML may be slow, due to the amount of coding changes required for existing HTML content to conform. It is anticipated that the introduction of mass HTML-to-XHTML conversion tools will become available to accelerate the acceptance rate of XHTML into the mainstream. Either way, it is likely inevitable that XHTML will eventually become the Web’s next global standard presentation language.

SOA Design Patterns by Thomas Erl
Foreword by Grady Booch
With contributions from David Chappell, Jason Hogg, Anish Karmarkar, Mark Little, David Orchard, Satadru Roy, Thomas Rischbeck, Arnaud Simon, Clemens Utschig, Dennis Wisnosky, and others.
Web Service Contract Design & Versioning for SOA by Thomas Erl, Anish Karmarkar, Priscilla Walmsley, Hugo Haas, Umit Yalcinalp, Canyang Kevin Liu, David Orchard, Andre Tost, James Pasley
SOA Principles of Service Design by Thomas Erl
Service-Oriented Architecture: A Field Guide to Integrating XML and Web Services by Thomas Erl
Service-Oriented Infrastructure:On-Premise and in the Cloud by Raj Balasubramanian, Benjamin Carlyle, Thomas Erl, Cesare Pautasso
Next Generation SOA:A Real-World Guide to Modern Service-Oriented Computing by Pethuru Cheliah, Thomas Erl, Clive Gee, Robert Laird, Berthold Maier, Hajo Normann, Leo Shuster, Bernd Trops, Clemens Utschig, Torsten Winterberg
SOA with .NET & Windows Azure: Realizing Service-Orientation with the Microsoft Platform by David Chou, John deVadoss, Thomas Erl, Nitin Gandhi, Hanu Kommalapati, Brian Loesgen, Christoph Schittko, Herbjorn Wilhelmsen, Mickey Williams
SOA Governance:
Governing Shared Services On-Premise & in the Cloud
by Stephen Bennett, Thomas Erl, Clive Gee, Anne Thomas Manes, Robert Schneider, Leo Shuster, Andre Tost, Chris Venable
SOA with Java by Raj Balasubramanian, David Chou, Thomas Erl, Thomas Plunkett, Satadru Roy, Philip Thomas, Andre Tost
Modern SOA Methodology: Methods for Applying Service-Orientation On-Premise & in the Cloud by Raj Balasubramanian, David Chou, Thomas Erl, Thomas Plunkett, Satadru Roy, Philip Thomas, Andre Tost
Cloud Computing: Concepts, Technology & Architecture by Thomas Erl, Zaigham Mahmood, Ricardo Puttini
Cloud Computing Design Patterns by Thomas Erl, Amin Naserpour

For more information about these books, visit: www.servicetechbooks.com


Arcitura Education Inc.
Arcitura Education Inc. is a leading global provider of progressive, vendor-neutral training and certification programs, providing industry-recognized certification programs for a range of certifications.
For more information:
www.arcitura.com
SOA Certified Professional (SOACP)
The books in this series are part of the official curriculum for the SOA Certified Professional program.
For more information:
www.soaschool.com
Cloud Certified Professional (CCP)
The books in this series are part of the official curriculum for the Cloud Certified Professional program.
For more information:
www.cloudschool.com
Big Data Science Certified Professional (BDSCP)
The books in this series are part of the official curriculum for the Big Data Science Certified Professional program.
For more information:
www.bigdatascienceschool.com/