title: load xsl which is using xslt in php
body: <p>recently we received a new xsl file which is using <a href="http://exslt.org" rel="nofollow">XSLT</a> namespace : </p>
  
  <blockquote>
    <p>xmlns:date="http://exslt.org/dates-and-times"</p>
  </blockquote>
  
  <p>and somewhere in the xsl it call following function:</p>
  
  <pre><code>&lt;xsl:value-of select="date:format-date(concat('1900-', @month, '-1'),'MMM')"/&gt;
  </code></pre>
  
  <p>the problem is the server is behind a proxy, so when i use following code it can't find the namespace and it through back error. </p>
  
  <p>this is how I call xsl file:</p>
  
  <pre><code>    $xsl_doc = new DOMDocument();
      $xsl_doc-&gt;load("stylesheet/report.xsl"); //load the stylesheet
      $xml_doc = new DOMDocument();
      $xml_doc-&gt;loadXML($xml); //load the xml
      $proc = new XSLTProcessor();
      $proc-&gt;importStylesheet($xsl_doc);
      $newdom = $proc-&gt;transformToDoc($xml_doc);
  </code></pre>
  
  <p>moreover when i enter this address in browswer<code>http://exslt.org/dates-and-times</code> it return error 404</p>
  
  <p>this is the error that I am getting at first place :</p>
  
  <pre><code>Warning: XSLTProcessor::transformToDoc() [xsltprocessor.transformtodoc]: runtime error: file file: stylesheet/section_b.xsl line 64 element value-of in \Application\_preview.php on line 25
  
  Warning: XSLTProcessor::transformToDoc() [xsltprocessor.transformtodoc]: XPath evaluation returned no result. in \Application\_preview.php on line 25
  </code></pre>
  
  <p>as you can see it throw error at line 64 which is the place <code>format-date</code> function is used</p>
  
  <p>in the <a href="http://exslt.org" rel="nofollow">XSLT</a> website is mentioned about importing the function into the xslt, so I download date.zip, extract and add following code to the xsl file, the first 3 line of the xsl become like following :</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  xmlns:response="http://ws.mywebsite.com.my/myosnet/response"
                  xmlns:date="http://exslt.org/dates-and-times"
                  version="1.0"&gt;
  
      &lt;xsl:import href="ext_module/date/date.xsl" /&gt;
  </code></pre>
  
  <p>then i tried to load again, but still it through back error </p>
  
  <pre><code>   Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: compilation error: file file: stylesheet/ext_module/date/functions/format-date/date.format-date.xsl line 5 element import in \Application\_preview.php on line 24
  
     Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: xsltParseStylesheetTop: ignoring misplaced import element in \Application\_preview.php on line 24
  
     Warning: XSLTProcessor::transformToDoc() [xsltprocessor.transformtodoc]: No stylesheet associated to this object in \Application\_preview.php on line 25
  
     Fatal error: Call to a member function saveHTML() on a non-object in \Application\_preview.php on line 26
  </code></pre>
  
  <p>I even tried to bring the function definition in the date.format.xsl but i failed.
  my question is how to add these custom functions. or how to make it to use proxy.</p>