title: Joomla <jdoc:include type="head" /> not rendering correctly - renders in <body> tag
body: <p>Recently I was migrating a web page from joomla 1.5 -> joomla 3.2.
  The template itself works great.
  The content is not displayed because of the  tag.</p>
  
  <p>The written code I have in my index is as:</p>
  
  <pre><code>&lt;?php
  defined('_JEXEC') or die('Restricted access'); // no direct access
  JHtml::_('behavior.framework',true);
  require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'functions.php';
  $document = null;
  if (isset($this))
      $document = &amp; $this;
  $baseUrl = $this-&gt;baseurl;
  $templateUrl = $baseUrl . '/templates/' . $this-&gt;template;
  
  artxComponentWrapper($document);
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html xml:lang="&lt;?php echo $this-&gt;language; ?&gt;" lang="&lt;?php echo $this-&gt;language; ?&gt;"
    xmlns:jdoc="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;head&gt;
    &lt;jdoc:include type="head" name="all" /&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
    &lt;meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /&gt;
    &lt;link rel="stylesheet" href="&lt;?php echo $this-&gt;baseUrl; ?&gt;/templates/system/css/system.css" type="text/css" /&gt;
    &lt;link rel="stylesheet" href="&lt;?php echo $this-&gt;baseUrl; ?&gt;/templates/system/css/general.css" type="text/css" /&gt;
    &lt;link rel="stylesheet" type="text/css" href="&lt;?php echo $templateUrl; ?&gt;/css/template.css" media="screen" /&gt;
  
    &lt;!--[if IE 7]&gt;&lt;link rel="stylesheet" href="&lt;?php echo $templateUrl; ?&gt;/css/template.ie7.css" type="text/css" media="screen" /&gt;&lt;![endif]--&gt;
    &lt;script type="text/javascript" src="&lt;?php echo $templateUrl; ?&gt;/script.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  ...
  &lt;/html&gt;
  </code></pre>
  
  <p>And this renders as:</p>
  
  <pre><code>&lt;html xml:lang="sl-si" lang="sl-si" xmlns:jdoc="http://www.w3.org/1999/XSL/Transform" class="chrome  win"&gt;
  &lt;head&gt;
    &lt;style type="text/css"&gt;&lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;jdoc:include type="head" name="all"&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"&gt;
      &lt;link rel="stylesheet" href="/templates/system/css/system.css" type="text/css"&gt;
      &lt;link rel="stylesheet" href="/templates/system/css/general.css" type="text/css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="/TKMS/templates/tkms_theme/css/template.css" media="screen"&gt;
      &lt;!--[if IE 7]&gt;&lt;link rel="stylesheet" href="/TKMS/templates/tkms_theme/css/template.ie7.css" type="text/css" media="screen" /&gt;&lt;![endif]--&gt;
      &lt;script type="text/javascript" src="/TKMS/templates/tkms_theme/script.js"&gt;&lt;/script&gt;
      &lt;!--CONTENT--&gt;..
    &lt;/jdoc:include&gt;
  </code></pre>
  
  <p>Why does this happen? How can I fix this? I read that this happens because of BOM, but I could not fix it.</p>