title: Using XSL template in HTML via PHP - correct method
body: <p>I have an XML feed (feefo) that I want to incorporate into an existing web page. I have the feed, I have an xsl file, and a vendor php file that invokes the transformation process. I'm using the following in my html to include the vendor php file:</p>
  
  <pre><code>&lt;?php include('feefo/feefofeedback-v2.php') ?&gt;
  </code></pre>
  
  <p>the script vendor php file like this:</p>
  
  <pre><code>&lt;?php
  $curdir = getcwd();
  
  $merchantidentifier = array_key_exists('merchantidentifier', $_GET) ? $_GET['merchantidentifier'] : 'smartmoneyonline';
  $limit = array_key_exists('limit', $_GET) ? $_GET['limit'] : null;
  $mode = array_key_exists('mode', $_GET) ? $_GET['mode'] : null;
  $vendorref = array_key_exists('vendorref', $_GET) ? $_GET['vendorref'] : null;
  $suppressnegatives = array_key_exists('suppressnegatives', $_GET) ? $_GET['suppressnegatives'] : null;
  
  $xml_filename = "http://cdn2.feefo.com/api/xmlfeedback?merchantidentifier=".$merchantidentifier;
  if ($limit)
    $xml_filename .= "&amp;limit=".$limit;
  if ($vendorref)
    $xml_filename.="&amp;vendorref=".$vendorref; 
  if ($mode)
    $xml_filename.="&amp;mode=".$mode; 
  if ($suppressnegatives)
    $xml_filename.="&amp;negativesanswered=true";
  
  if (phpversion() &lt; "5"){
    $xmldoc = domxml_open_file( $xml_filename);
    $xsldoc = domxml_xslt_stylesheet_file ( $curdir."/feefo/feedback.xsl");
    $result = $xsldoc-&gt;process($xmldoc);
    echo $result-&gt;dump_mem();
  }
  else
  {
    $doc = new DOMDocument();
    $xsl = new XSLTProcessor();
    $doc-&gt;load($curdir."/feefo/feedback.xsl");
    $xsl-&gt;importStyleSheet($doc);
    $doc-&gt;load($xml_filename);
    echo $xsl-&gt;transformToXML($doc);
  }
  
  ?&gt;
  </code></pre>
  
  <p>Though it works, I'm not sure I'm implementing this correctly because the xsl file includes html, head, body etc. Here's the beginning of the xsl file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt; 
  &lt;?xml-stylesheet type="text/css" href="style.css"?&gt;
   &lt;html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt;
      &lt;xsl:variable name="feefostarsimageroot" select="'http://cdn.feefo.com/feefo/resources/images/rating'" /&gt;
  &lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
      &lt;title&gt;FeeFo Feedback&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="style.css" /&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id="page" itemtype="http://schema.org/LocalBusiness" itemscope="itemscope"&gt;
   &lt;!-- tr class=row --&gt;
         &lt;div class="comments"&gt;
  
             &lt;xsl:for-each select="FEEDBACKLIST/SUMMARY"&gt;
                 &lt;h1&gt;&lt;span itemprop="name"&gt;......
  </code></pre>
  
  <p>Obviously the page doesn't validate because I have the parent html, head, body elements, as well as those contained in the xsl file. If I remove those elements in the xsl file, the xml feed no longer works as I get:</p>
  
  <blockquote>
    <p>Message: DOMDocument::load(): Namespace prefix xsl on for-each is not defined</p>
  </blockquote>
  
  <p>Have I approached this in the right way? If so, how do I remove the offending elements from the xsl file and still have it work?</p>