function XML_CSSML_libxslt($in_CSSML = null, $in_type = 'string', $in_params = null)
 {
     $this->loaded = false;
     if (!is_null($in_CSSML)) {
         $this->load($in_CSSML, $in_type);
     }
     if (!is_null($in_params)) {
         $this->setParams($in_params);
     }
     $this->stylesheetDoc = domxml_xslt_stylesheet_file(dirname(__FILE__) . '/libxslt.xsl');
 }
Exemplo n.º 2
0
 function process()
 {
     global $gConf;
     if ('client' == $gConf['xsl_mode']) {
         echo 'depricated';
         exit;
     }
     header($this->_header);
     // xml: string, xsl: file
     if (!($this->_mode & BXXSLTRANSFORM_XML_FILE) && $this->_mode & BXXSLTRANSFORM_XSL_FILE) {
         $args = array('/_xml' => $this->_xml);
         validate_unicode($this->_xml);
         if ((int) phpversion() >= 5) {
             $xml = new DOMDocument();
             if (!@$xml->loadXML($this->_xml)) {
                 $mk = new Mistake();
                 $mk->log("BxXslTransform::process - can not load xml:\n " . $this->_xml);
                 $mk->displayError("[L[Site is unavailable]]");
             }
             $xsl = new DomDocument();
             $xsl->load($this->_xsl);
             $proc = new XsltProcessor();
             $proc->importStyleSheet($xsl);
             $res = $proc->transformToXML($xml);
         } else {
             if (function_exists('domxml_xslt_stylesheet_file')) {
                 $xmldoc = new DomDocument($this->_xml);
                 $xsldoc = domxml_xslt_stylesheet_file($this->_xsl);
                 $result = $xsldoc->process($xmldoc);
                 $res = $xsldoc->result_dump_mem($result);
             } elseif (function_exists('xslt_create')) {
                 $xh = xslt_create();
                 xslt_setopt($xh, XSLT_SABOPT_IGNORE_DOC_NOT_FOUND);
                 $res = xslt_process($xh, 'arg:/_xml', $this->_xsl, NULL, $args);
                 xslt_free($xh);
             } else {
                 die('Server XSLT support is not enabled, try to use client XSL transformation http://your-domain/orca_folder/?xsl_mode=client');
             }
         }
         return $res;
     }
     // xml: file, xsl: file
     if ($this->_mode & BXXSLTRANSFORM_XML_FILE && $this->_mode & BXXSLTRANSFORM_XSL_FILE) {
         if ((int) phpversion() >= 5) {
             $xml = new DOMDocument();
             $xml->load($this->_xml);
             $xsl = new DomDocument();
             $xsl->load($this->_xsl);
             $proc = new XsltProcessor();
             $proc->importStyleSheet($xsl);
             $res = $proc->transformToXML($xml);
         } else {
             if (function_exists('domxml_xslt_stylesheet_file')) {
                 $xmldoc = new DomDocument($this->_xml);
                 $xsldoc = domxml_xslt_stylesheet_file($this->_xsl);
                 $result = $xsldoc->process($xmldoc);
                 $res = $xsldoc->result_dump_mem($result);
             } elseif (function_exists('xslt_create')) {
                 $xh = xslt_create();
                 $res = xslt_process($xh, $this->_xml, $this->_xsl, NULL, $args);
                 xslt_setopt($xh, XSLT_SABOPT_IGNORE_DOC_NOT_FOUND);
                 xslt_free($xh);
             } else {
                 die('XSLT support is not enabled');
             }
         }
         return $res;
         //return  `/opt/jre1.5.0_06/bin/java -jar /opt/saxon/saxon.jar -ds {$this->_xml} {$this->_xsl}`;
     }
     return "<h1>not supported</h1>";
 }
Exemplo n.º 3
0
function Transform($xslfile, $xml, $return = false)
{
    if (Param('_Debug')) {
        header("Content-type: text/xml");
        print $xml;
        exit;
    }
    if (5 == 5) {
        if (class_exists('xsltCache')) {
            $xslt = new xsltCache();
            $xslt->importStyleSheet(TPL_DIR . $xslfile);
        } else {
            $xslt = new xsltProcessor();
            $xsltDoc = DomDocument::load(TPL_DIR . $xslfile);
            $xslt->importStyleSheet($xsltDoc);
        }
        //    $result = $xslt->transformToXML(DomDocument::loadXML($xml));
        $doc = new DOMDocument();
        $load_succesfull = @$doc->loadXML($xml);
        if (!$load_succesfull) {
            $result = $xslt->transformToXML(iceERROR('XML', $xml));
        } else {
            $result = $xslt->transformToXML($doc);
        }
    } else {
        //    ob_end_clean();
        $xslt = domxml_xslt_stylesheet_file(TPL_DIR . $xslfile);
        $dom = @domxml_open_mem($xml);
        if (!$dom) {
            $dom = domxml_open_mem(iceERROR('XML', $xml));
        }
        $final = $xslt->process($dom);
        print serialize($xslt);
        exit;
        $load_end_time = microtime(true);
        $result = $xslt->result_dump_mem($final);
        unset($dom);
        unset($xslt);
    }
    if (!$return) {
        header("Content-type: text/html");
        print $result;
    } else {
        //print $b; // ajax "<sajax>" string
        return $result;
    }
}
Exemplo n.º 4
0
<?php

/**
 * Create a CopixDao schema from a creation one: first step (see doCopixSchema2.php)
 * Use Pear::MDB library
 * 
 */
define('LIB_MDB', '');
require_once LIB_MDB . 'MDB.php';
MDB::loadFile('Manager');
$creation_schema_file = 'mdb-schema.xml';
$CopixDao_schema_file = 'dao-definition0.xml';
// load a document
$source = domxml_open_file(realpath($creation_schema_file));
// load thefirst style sheet
$stylesheet = domxml_xslt_stylesheet_file(realpath('e2a.xsl'));
// apply the style sheet to the document
$result = $stylesheet->process($source, array('with-namespace' => 'no'));
// save the styled document
$result->dump_file(realpath($CopixDao_schema_file));
echo "\n<br>End of process #0. \n<br>";
 /**
 Transforme le document DOM XML donné en autre chose grace à la feuille de style donnée.
 TODO: Support de transformation en cascade, avec plusieurs feuilles de style ?
 */
 function xml_vers_html($domxml, $fichier_xslt)
 {
     if (!$this->USE_SABLOTRON) {
         //libxslt
         $xsltproc = domxml_xslt_stylesheet_file(getcwd() . "/" . $fichier_xslt);
         $result = $xsltproc->process($domxml, $this->xslt_params);
         //return $result->dump_mem(); // Effet de bord : le résultat contient l'entete XML [?xml version... ?]
         return $xsltproc->result_dump_mem($result);
         // Mais on ne veux pas forcement cette entete. C'est à la feuille de style de le décider.
     } else {
         //Sablotron
         $xml = $domxml->dump_mem(true, "UTF-8");
         $arguments = array('/_xml' => $xml);
         $xp = xslt_create();
         $result = xslt_process($xp, 'arg:/_xml', getcwd() . "/" . $fichier_xslt, NULL, $arguments, $this->xslt_params);
         xslt_free($xp);
         return $result;
     }
 }
Exemplo n.º 6
0
    {
        $this->test_var4 = $value;
        echo "test_var4 property set to {$value}<br />\n";
        return true;
    }
    function disp()
    {
        echo "<pre>";
        var_dump($this);
        echo "</pre>";
    }
}
$obj = new test_class(1, 'arg2');
$obj->set_var1('test1');
$obj->set_var2(123);
$obj->set_var3($a);
/* Array from previous test */
$obj->set_var4(array(1, 2, 3, 4, 5, 6, 7, 8, 9));
$obj->disp();
?>
<h2>And finally a bit of XML and XSLT</h2>
<?php 
$xml = domxml_open_file('presentations/slides/intro/menu.xml');
$xsl = domxml_xslt_stylesheet_file('presentations/slides/intro/menu.xsl');
$out = $xsl->process($xml);
echo $out->dump_mem();
?>
</p>
</body>
</html>
Exemplo n.º 7
0
    $xslFile = $root . $path . "/" . stripslashes($_POST['xslFile']);
    if (!preg_match("/^" . preg_quote(realpath($root), "/") . "/", realpath($xslFile))) {
        trigger_error("Illegal filename '{$xslFile}'");
    }
    $arrXslParam = array();
    if (isset($_POST['xslParam'])) {
        $xslParam = $_POST['xslParam'];
        // encoded as param_name1,value1,param_name2,value2
        $arrXsl = split(",", $xslParam);
        for ($i = 0; $i < count($arrXsl); $i += 2) {
            $arrXslParam[$arrXsl[$i]] = $arrXsl[$i + 1];
        }
    }
    $xmlDoc = domxml_open_mem($xmlData, DOMXML_LOAD_DONT_KEEP_BLANKS);
    if ($xmlDoc) {
        $xslDoc = domxml_xslt_stylesheet_file($xslFile);
        if (!$xslDoc) {
            trigger_error("XSL_TRANSFORMATION: Load XSL failed. File path was: {$xslFile}.\n");
        }
        $transformedData = $xslDoc->process($xmlDoc, $arrXslParam);
        if (!$transformedData) {
            trigger_error("XSL_TRANSFORMATION: Transformation failed.\n");
        }
        $xhtmlOuput = str_replace('<?xml version="1.0"?>', '', $xslDoc->result_dump_mem($transformedData));
        header("HTTP/1.0 200 Ok");
        header('Content-Type: text/xml');
        echo $xhtmlOuput;
    } else {
        trigger_error("XSL_TRANSFORMATION: Parsing Error. Data was: {$xmlData}.\n");
    }
} else {
Exemplo n.º 8
0
require_once 'classes/Session.inc';
Session::logcheck("MenuIntelligence", "CorrelationDirectives");
require_once 'ossim_conf.inc';
require_once 'classes/Security.inc';
$conf = $GLOBALS["CONF"];
if (version_compare(PHP_VERSION, '5', '>=') && extension_loaded('xsl')) {
    require_once 'domxml-php4-to-php5.php';
}
$XML_FILE = '/etc/ossim/server/directives.xml';
$XSL_FILE = $conf->get_conf("base_dir") . '/directives/directivemenu.xsl';
if (GET('css_stylesheet')) {
    $css_stylesheet = GET('css_stylesheet');
} else {
    $css_stylesheet = 'directives.css';
}
$array_params = array('css_stylesheet' => $css_stylesheet);
if (!function_exists('domxml_xslt_stylesheet_file')) {
    require_once "ossim_error.inc";
    $error = new OssimError();
    $error->display("PHP_DOMXML");
}
if (!is_file($XSL_FILE)) {
    die(_("Missing required XSL file") . " '{$XSL_FILE}'");
}
if (!is_file($XML_FILE)) {
    die(_("Missing required XML file") . " '{$XML_FILE}'");
}
$xslt = domxml_xslt_stylesheet_file($XSL_FILE);
$xml = domxml_open_file($XML_FILE, DOMXML_LOAD_SUBSTITUTE_ENTITIES);
$html = $xslt->process($xml, $array_params);
echo $html->dump_mem(true);
Exemplo n.º 9
0
<?php

$stylesheet = "../docbook-book.xsl";
$xmldoc = domxml_open_file("../book.xml");
$xsldoc = domxml_xslt_stylesheet_file($stylesheet);
$result = $xsldoc->process($xmldoc);
echo $xsldoc->result_dump_file($result, "filename");
?>
 
Exemplo n.º 10
0
//  $vendorref can be used if you want the feedback for particular products, for which you have sent unique vendorrefs
//  $vendorref may contain wildcards  (e.g.   *SKU1234*  would pick up a feedback on 'SKU1234 THURSDAY'
//  You could also pass various other parameters - see the parameters passed at the top of the feedback viewing page on the Feefo site.
// have added mode, can be product or service or both
$logon = array_key_exists('logon', $_GET) ? $_GET['logon'] : null;
$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;
$xml_filename = "http://www.feefo.com/feefo/xmlfeed.jsp?logon=" . $logon;
if ($limit) {
    $xml_filename .= "&limit=" . $limit;
}
if ($vendorref) {
    $xml_filename .= "&vendorref=" . $vendorref;
}
if ($mode) {
    $xml_filename .= "&mode=" . $mode;
}
if (phpversion() < "5") {
    $xmldoc = domxml_open_file($xml_filename);
    $xsldoc = domxml_xslt_stylesheet_file($curdir . "/feedback.xsl");
    $result = $xsldoc->process($xmldoc);
    echo $result->dump_mem();
} else {
    $doc = new DOMDocument();
    $xsl = new XSLTProcessor();
    $doc->load($curdir . "/summary_microdata.xsl");
    $xsl->importStyleSheet($doc);
    $doc->load($xml_filename);
    echo $xsl->transformToXML($doc);
}