How to write PHP in XSLT



PHP Snippet 1:

<xsl:output omit-xml-declaration="yes" method="html" />

PHP Snippet 2:

<?php 
                        echo 'OK IT DOESN't WORK!!!!!!!!!!!!!!!!!!!';
                        ?>

PHP Snippet 3:

<?php
$xmlUri      = '/some/path/to/your.xml';
$xslUri      = '/some/path/to/your.xsl';
$xmlDocument = new DOMDocument;
$xslDocument = new DOMDocument;

if ($xmlDocument->load($xmlUri) && $xslDocument->load($xslUri)) {

    $xsltProc = new XSLTProcessor();
    $xsltProc->setParam('pi', "OK IT DOESN't WORK!!!!!!!!!!!!!!!!!!!");
    if ($xsltProc->importStyleSheet($xslDocument)) {
        echo $xsltProc->transformToXML($xmlDocument);
    }
}

PHP Snippet 4:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:param name="pi"/>
  <xsl:output omit-xml-declaration="yes" method="xml" />
  <xsl:template match="/">
    <html> 
      <head>
      </head>
      <body bgcolor="#000">
        <div class="main" style="background:lightblue;">
          <xsl:processing-instruction name="php">
            <xsl:value-of select="$pi"/>
          </xsl:processing-instruction>
          <xsl:for-each select="webpage/content/main">
            <a href="{link}" style="color:#000; text-decoration:none;">
              <h1><xsl:value-of select="heading" /></h1>
              <h2><xsl:value-of select="subheading" /></h2>
              <div class="img">
                <img src="../images/{image}" width="100%" height="auto"/>
              </div>
              <xsl:value-of select="description" />
            </a>
          </xsl:for-each>
        </div>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>