The following code shows how to indicate to the XSLT processor that you want your output to be XHTML conformant:
<xsl:output method="xml" indent="yes" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
The xsl:output element is a top-level element which instructs the XSLT processor how to write the output stream to a serial output file.
The following code is inserted in the output as a result of the xsl:output element:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
References: [XSLT Programmer's Reference pp. 250-261]
XHTML 1.0 is a reformulation of HTML 4 as an XML 1.0 compliant grammer.
The benefits of migrating HTML content to XHTML are related to the large number of tools available for developing and deploying XML compliant content.
If you are developing XSLT applications which transform XML to HTML, it makes a lot of sense to be conformant with XHTML 1.0.
The Web Standards Project (WaSP) is a vocal advocacy for consistent HTML, CSS, and XML support in all browsers. Read their FAQ to understand why this is important for the web community.
These are some of the core differences which distinguish XHTML from HTML:
For a more detailed description of XHTML see the excellent webreview.com article, XHTML: Our last, best hope for clean code.
XHTML Transitional is a version of XHTML which allows you to employ styling in your HTML. In contrast, XHTML Strict requires all styling to be done using CSS. There are separate DTD's for each version. The DTD's enforce conformance to these rules. It is therefore easier to convert existing HTML to XHTML Transitional than to XHTML Strict.
There is an excellent validator at the World Wide Web Consortium (W3C) site which is available for free to validate your web pages for XHTML conformance.
If your pages are validated then you get to decorate them with the following XHTML certification seal:
You also get to insert the following code in your XHTML to prove your certification to any skeptics. The code displays the certification seal as a button that your readers may press to invoke the validation program on the referring page (i.e. your XHTML page).
<p> <a href="http://validator.w3.org/check/referer"> <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /> </a> </p>
XML Spy 3.0 is a very popular XML editor which may be used to validate XHTML using the XHTML DTD's. In order to have XML Spy validate your XHTML, change the file suffix from '.html' to '.xml'. If you have set up your DOCTYPE as described above, XML Spy will read the DTD using the URL specified and use it to perform the validation.
HTML Tidy is a free, open-source utility which may be used to migrate existing HTML to XHTML. It is quite a powerful tool, comparable to a many-bladed Swiss Army knife because of the large number of configuration options it provides.
If you want to download the DTD's used to validate XHTML, you may find them using the following links: