title: Pass PHP DOM to XSLT
body: <p>I'm trying to load XML in a PHP document and pass it to an XSLT.  I'm able to load the XML file directly into the XSLT, but I'm trying to avoid using actual files and instead just use cURL to get my data.  </p>
  
  <p>Here's my PHP script:</p>
  
  <pre><code>&lt;?php
  
  header("Content-type: text/xml");
  
  $ch = curl_init("domain1.com/sample1.php");
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $output = curl_exec($ch);       
  curl_close($ch);
  $sample1 = new DOMDocument();
  $sample1-&gt;formatOutput = true;
  $sample1-&gt;loadXML($output);
  $sample1-&gt;save("sample1.xml");
  
  $ch = curl_init("domain1.com/sample2.php");
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $output = curl_exec($ch);       
  curl_close($ch);
  $sample2 = new DOMDocument();
  $sample2-&gt;formatOutput = true;
  $sample2-&gt;loadXML($output);
  $sample2-&gt;save("sample2.xml");
  
  /* load the xml file and stylesheet as domdocuments */
  $xsl = new DomDocument();
  $xsl-&gt;load("transform.xsl");
  
  /* create the processor and import the stylesheet */
  $proc = new XsltProcessor();
  $xsl = $proc-&gt;importStylesheet($xsl);
  
  $mergedxml = new DomDocument();
  $mergedxml-&gt;loadXML($proc-&gt;transformToXML($sample1));
  echo $mergedxml-&gt;saveXML();
  $mergedxml-&gt;save("results.xml");
  
  ?&gt;
  </code></pre>
  
  <p>Here's the line from my XSLT file that uses the second file (sample2.xml):</p>
  
  <pre><code>&lt;xsl:variable name="input2" select="document('sample2.xml')/DATA"/&gt;
  </code></pre>
  
  <p>I know you can call some PHP functions within XLST, but I can't seem to figure out how to pass the XML DOMDocument directly to XSLT without first saving to a file.  Is this possible?  Or do I need to do this a different way?  I'm pretty new to PHP and XSLT so any help is appreciated.</p>
  
  <p>Thanks.</p>