<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Common Media, Inc. &#187; namespaces</title>
	<atom:link href="http://www.commonmediainc.com/tag/namespaces/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.commonmediainc.com</link>
	<description>Online Communities and Web Development</description>
	<lastBuildDate>Fri, 06 May 2011 15:10:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>XSL namespaces for HTML output</title>
		<link>http://www.commonmediainc.com/2009/07/15/xsl-namespaces-for-html-output/</link>
		<comments>http://www.commonmediainc.com/2009/07/15/xsl-namespaces-for-html-output/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 20:30:08 +0000</pubDate>
		<dc:creator>pjmorse</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[namespaces]]></category>
		<category><![CDATA[xhtml]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xsl]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://www.commonmediainc.com/?p=114</guid>
		<description><![CDATA[One of our current projects involves an application where certain PHP scripts request XML from a SOAP service, then use XSL templates combined with parameters set by the PHP script to generate XHTML from that XML.  (Follow that? If not, you may be able to safely skip this.) We haven&#8217;t had to cope with setting [...]]]></description>
			<content:encoded><![CDATA[<p>One of our current projects involves an application where certain <abbr title="Hypertext PreProcessor">PHP</abbr> scripts request <abbr title="eXtensible Markup Language">XML</abbr> from a <abbr title="ahh, whatever">SOAP</abbr> service, then use <abbr title="XML Style Language">XSL</abbr> templates combined with parameters set by the PHP script to generate <abbr title="HyperText Markup Language">XHTML</abbr> from that XML.  (Follow that? If not, you may be able to safely skip this.) We haven&#8217;t had to cope with setting up this system, but we did have to update the HTML produced by the <abbr title="XSL Transformation">XSLT</abbr>, if that&#8217;s the proper verb.</p>
<p>The problem we ran in to was getting around Internet Explorer&#8217;s <a href="http://www.quirksmode.org/css/quirksmode.html">quirks mode</a>. The original XSL templates use a bare <code>xsl:output</code> tag with few options, and a bare <code>html</code> tag to start the output code as well, like this:</p>
<pre>&lt;xsl:output method="html" indent="yes"/&gt;
&lt;html&gt;</pre>
<p>This produces HTML with no document type and no <a href="http://www.xml.com/pub/a/2001/04/04/trxml/index.html">XML namespace</a>, which means IE is going to go to Quirks Mode, which we don&#8217;t want because it hurts our carefully-crafted <abbr title="Cascading Style Sheets">CSS</abbr>. We want something more like this:</p>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/
xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:
lang="en" lang="en"&gt;</pre>
<p>First, we tried just adding the <code>xmlns</code> attributes to our <code>html</code> tag. This didn&#8217;t really help: it added extraneous <code>xmlns=""</code> attributes to many of the child tags in the output document, which quirkified <abbr title="Internet Explorer">IE</abbr> just as much as not having the tag.</p>
<p>Solving the second part of the first problem (<a href="http://www.xml.com/pub/a/2002/09/04/xslt.html?page=2">producing a document type tag</a>) turned out to also be the solution to the second problem (extraneous <code>xmlns</code> attributes). XSLT will add a document type tag automatically if the appropriate attributes are given to the <code>xsl:output</code> tag. Specifically, we wound up with this:</p>
<pre>&lt;xsl:output method="html" indent="yes" encoding="utf-8"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" /&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;</pre>
<p>Notice the bonus <code>encoding</code>, <code>doctype-public</code> and <code>doctype-system</code> attributes. That got us the <code>DOCTYPE</code> tag shown above, and bailed us out of IE Quirks Mode.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.commonmediainc.com/2009/07/15/xsl-namespaces-for-html-output/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

