XSL and DTD

by Pascal Opitz

published 11 April 2006

A quick code snippet to include the right XHTML DTD in your XSL generated output. This took me a bit of reseach to find out:

<xsl:text disable-output-escaping="yes">
<![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">]]>
</xsl:text>

Include this into you template and switch the output method to “xsl” and you should be fine.

Comment

  1. this is simpler:

    <xsl:output 
    method="xml" 
    encoding="utf-8" 
    omit-xml-declaration="yes" 
    indent="no" 
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" 
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" />
    

    — Anup Shah    11 April, 2:12pm    #
  2. Thanks a lot Anup, it definitely is … but even more important: it's way cleaner!
    Pascal    11 April, 2:22pm    #
  3. Another tidbit I found today was: exclude-result-prefixes="media" to exclude unwanted namespace declarations from the output. Handy…
    Mike Stenhouse    17 April, 3:58pm    #

Have your say

If your comment doesn't show up straight away, please don't be offended - we're not censoring, we are just trying to keep out all the viagra and poker ads. Thanks to an explosion of spam all comments are held for manual green-lighting.

name Remember
email
http://
Message <?>

Quick links

Other people's articles that we think you might be interested in: