当前位置: 首页>>代码示例>>PHP>>正文


PHP XsltProcessor::transformToXml方法代码示例

本文整理汇总了PHP中XsltProcessor::transformToXml方法的典型用法代码示例。如果您正苦于以下问题:PHP XsltProcessor::transformToXml方法的具体用法?PHP XsltProcessor::transformToXml怎么用?PHP XsltProcessor::transformToXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XsltProcessor的用法示例。


在下文中一共展示了XsltProcessor::transformToXml方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _processTransform

 protected function _processTransform(DomDocument $domDocument, DomDocument $xslTemplate)
 {
     $this->_processor->importStylesheet($xslTemplate);
     $transformedXml = $this->_processor->transformToXml($domDocument);
     $transformedXml = str_replace(array("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "<?xml version=\"1.0\"?>\n"), '', $transformedXml);
     return $transformedXml;
 }
开发者ID:kandy,项目名称:system,代码行数:7,代码来源:Xslt.php

示例2: transform

 /**
  * Simple, dynamic xsl transform
  */
 protected function transform($xml, $path_to_xsl, $output_type = null, array $params = array(), array $import_array = array(), $to_string = true)
 {
     if ($path_to_xsl == "") {
         throw new \Exception("no stylesheet supplied");
     }
     // make sure we have a domdocument
     if (is_string($xml)) {
         $xml = Parser::convertToDOMDocument($xml);
     }
     // create xslt processor
     $processor = new \XsltProcessor();
     $processor->registerPhpFunctions();
     // add parameters
     foreach ($params as $key => $value) {
         $processor->setParameter(null, $key, $value);
     }
     // add stylesheet
     $xsl = $this->generateBaseXsl($path_to_xsl, $import_array, $output_type);
     $processor->importStylesheet($xsl);
     // transform
     if ($to_string == true) {
         return $processor->transformToXml($xml);
     } else {
         return $processor->transformToDoc($xml);
     }
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:29,代码来源:Xsl.php

示例3: render

 /**
  * Render the table.
  *
  * @param mixed $tableDom
  * @param mixed $config
  */
 public function render(Document $reportDom, Config $config)
 {
     $template = $config['template'];
     $out = $config['file'];
     if (!file_exists($template)) {
         throw new \RuntimeException(sprintf('XSLT template file "%s" does not exist', $template));
     }
     $stylesheetDom = new \DOMDocument('1.0');
     $stylesheetDom->load($template);
     $xsltProcessor = new \XsltProcessor();
     $xsltProcessor->importStylesheet($stylesheetDom);
     $xsltProcessor->setParameter(null, 'title', $config['title']);
     $xsltProcessor->setParameter(null, 'phpbench-version', PhpBench::VERSION);
     $xsltProcessor->setParameter(null, 'date', date('Y-m-d H:i:s'));
     $output = $xsltProcessor->transformToXml($reportDom);
     if (!$output) {
         throw new \InvalidArgumentException(sprintf('Could not render report with XSL file "%s"', $template));
     }
     if (null !== $out) {
         file_put_contents($out, $output);
         $this->output->writeln('Dumped XSLT report:');
         $this->output->writeln($out);
     } else {
         $this->output->write($output);
     }
 }
开发者ID:pborreli,项目名称:phpbench,代码行数:32,代码来源:XsltRenderer.php

示例4: transform

 /**
  * Simple XSLT transformation function
  * 
  * @param mixed $xml			DOMDocument or string containing xml
  * @param string $strXsltPath	Relative file path to xslt document. Will look in both library location and 
  * 								local app location for documents, and combine them so local overrides library 
  * 								templates, if neccesary. 
  * @param array $arrParams		[optional] array of parameters to pass to stylesheet
  * @param bool $bolDoc			[optional] return result as DOMDocument (default false)
  * @param array $arrInclude		[optional] additional stylesheets that should be included in the transform
  * @return mixed				newly formatted document as string or DOMDocument
  * @static 
  */
 public static function transform($xml, $strXsltPath, $arrParams = null, $bolDoc = false, $arrInclude = array())
 {
     if ($strXsltPath == "") {
         throw new Exception("no stylesheet supplied");
     }
     if (is_string($xml)) {
         // load xml document from string
         $objXml = new DOMDocument();
         $objXml->loadXML($xml);
         $xml = $objXml;
     }
     $objXsl = self::generateBaseXsl($strXsltPath, $arrInclude);
     // create XSLT Processor
     $objProcessor = new XsltProcessor();
     $objProcessor->registerPhpFunctions();
     if ($arrParams != null) {
         // add in parameters
         foreach ($arrParams as $key => $value) {
             $objProcessor->setParameter(null, $key, $value);
         }
     }
     // transform
     $objXsl = $objProcessor->importStylesheet($objXsl);
     if ($bolDoc == true) {
         return $objProcessor->transformToDoc($xml);
     } else {
         return $objProcessor->transformToXml($xml);
     }
 }
开发者ID:laiello,项目名称:xerxes-portal,代码行数:42,代码来源:Parser.php

示例5: applyTemplate

/**
 * Metainformation catalogue
 * --------------------------------------------------
 *
 * Lib_XML for MicKa
 *
 * @link       http://www.bnhelp.cz
 * @package    Micka
 * @category   Metadata
 * @version    20121206
 *
 */
function applyTemplate($xmlSource, $xsltemplate)
{
    $rs = FALSE;
    if (File_Exists(CSW_XSL . '/' . $xsltemplate)) {
        if (!extension_loaded("xsl")) {
            if (substr(PHP_OS, 0, 3) == "WIN") {
                dl("php_xsl.dll");
            } else {
                dl("php_xsl.so");
            }
        }
        $xp = new XsltProcessor();
        $xml = new DomDocument();
        $xsl = new DomDocument();
        $xml->loadXML($xmlSource);
        $xsl->load(CSW_XSL . '/' . $xsltemplate);
        $xp->importStyleSheet($xsl);
        //$xp->setParameter("","lang",$lang);
        $xp->setParameter("", "user", $_SESSION['u']);
        $rs = $xp->transformToXml($xml);
    }
    if ($rs === FALSE) {
        setMickaLog('applyTemplate === FALSE', 'ERROR', 'micka_lib_xml.php');
    }
    return $rs;
}
开发者ID:riskatlas,项目名称:micka,代码行数:38,代码来源:micka_lib_xml.php

示例6: xhtmlAction

 public function xhtmlAction()
 {
     $xml = DOCS_PATH . $this->view->docid . '.xml';
     $xsl = APPLICATION_PATH . 'modules/contingent/controllers/xml2html.xsl';
     $doc = new DOMDocument();
     $doc->substituteEntities = TRUE;
     $doc->load($xsl);
     $proc = new XsltProcessor();
     $proc->importStylesheet($doc);
     $doc->load($xml);
     $proc->setParameter('', 'contextPath', '/');
     $proc->setParameter('', 'nodeResPath', '/res/' . $this->view->docid . '/');
     echo $proc->transformToXml($doc);
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:14,代码来源:TypecontentController.php

示例7: xsltTransform

 private function xsltTransform($xmlStr, $xslFile, $toDom = false)
 {
     $doc = new DOMDocument();
     $doc->substituteEntities = TRUE;
     //		$doc->resolveExternals = TRUE;
     $doc->load($xslFile);
     $proc = new XsltProcessor();
     $proc->importStylesheet($doc);
     $doc->loadXML($xmlStr);
     if ($toDom) {
         return $proc->transformToDoc($doc);
     } else {
         return $proc->transformToXml($doc);
     }
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:15,代码来源:QuestionEditorValuesFilter.php

示例8: xhtmlAction

 public function xhtmlAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $xml = DOCS_PATH . $this->view->docid . '.xml';
     $xsl = APPLICATION_PATH . 'modules/site/controllers/xml2html.xsl';
     $doc = new DOMDocument();
     $doc->substituteEntities = TRUE;
     $doc->load($xsl);
     $proc = new XsltProcessor();
     $proc->importStylesheet($doc);
     @$doc->load($xml);
     $proc->setParameter('', 'contextPath', '/');
     $proc->setParameter('', 'nodeResPath', '/res/' . $this->view->docid . '/');
     $proc->registerPHPFunctions('TypecontentController::widget');
     echo $proc->transformToXml($doc);
 }
开发者ID:TDMU,项目名称:contingent5_statserver,代码行数:16,代码来源:TypecontentController.php

示例9: render

 /**
  * Render the table.
  *
  * @param mixed $tableDom
  * @param mixed $config
  */
 public function render(Document $reportDom, Config $config)
 {
     $template = $config['template'];
     $out = strtr($config['file'], ['%report_name%' => $reportDom->firstChild->getAttribute('name')]);
     if (!file_exists($template)) {
         throw new \RuntimeException(sprintf('XSLT template file "%s" does not exist', $template));
     }
     foreach ($reportDom->query('.//row') as $rowEl) {
         $formatterParams = [];
         foreach ($rowEl->query('./formatter-param') as $paramEl) {
             $formatterParams[$paramEl->getAttribute('name')] = $paramEl->nodeValue;
         }
         foreach ($rowEl->query('./cell') as $cellEl) {
             $value = $cellEl->nodeValue;
             if ('' !== $value && $cellEl->hasAttribute('class')) {
                 $classes = explode(' ', $cellEl->getAttribute('class'));
                 $value = $this->formatter->applyClasses($classes, $value, $formatterParams);
                 $cellEl->nodeValue = $value;
             }
         }
     }
     $stylesheetDom = new \DOMDocument('1.0');
     $stylesheetDom->load($template);
     $xsltProcessor = new \XsltProcessor();
     $xsltProcessor->importStylesheet($stylesheetDom);
     $xsltProcessor->setParameter(null, 'title', $config['title']);
     $xsltProcessor->setParameter(null, 'phpbench-version', PhpBench::VERSION);
     $xsltProcessor->setParameter(null, 'date', date('Y-m-d H:i:s'));
     $output = $xsltProcessor->transformToXml($reportDom);
     if (!$output) {
         throw new \InvalidArgumentException(sprintf('Could not render report with XSL file "%s"', $template));
     }
     if ($out) {
         file_put_contents($out, $output);
         $this->output->writeln('Dumped XSLT report:');
         $this->output->writeln($out);
     } else {
         $this->output->write($output);
     }
 }
开发者ID:dantleech,项目名称:phpbench,代码行数:46,代码来源:XsltRenderer.php

示例10: do_transformation

function do_transformation($xml, $xsl, &$result, $option)
{
    if ($option == 'xml') {
        header("Content-type: application/xml");
        $result = $xml;
        return 1;
    } else {
        if ($option == 'xsl') {
            /**
             * Compatibility function wrappers. These are function's wrappers that make
             * available functions found on newer PHP versions (mostly 4.3 ones).
             */
            $version = explode(".", phpversion());
            $major = $version[0];
            $minor = $version[1];
            $release = $version[2];
            if ($major >= 5) {
                $xmlDOM = new DomDocument();
                $xslDOM = new DomDocument();
                $xsltEngine = new XsltProcessor();
                $xmlDOM->loadXML($xml);
                $xslDOM->load($xsl);
                $xsltEngine->importStylesheet($xslDOM);
                $transformation = $xsltEngine->transformToXml($xmlDOM);
                echo $transformation;
                return 1;
            } else {
                $xsl_proc = xslt_create();
                xslt_set_encoding($xsl_proc, "ISO-8859-1");
                $arg = array('/_xml' => $xml);
                $result = xslt_process($xsl_proc, $xml, $xsl, NULL, $arg);
                xslt_free($xsl_proc);
                return 1;
            }
        } else {
            return 0;
        }
    }
}
开发者ID:magsilva,项目名称:NoRiskPlanning,代码行数:39,代码来源:xsl_handler.php

示例11: DOMDocument

            </SERVE>';
    }
    $body .= '</serves>';
    $body = utf8_encode($body);
    if ($_POST["generate"] == "server") {
        # LOAD XML FILE
        $dom_content = new DOMDocument();
        $dom_content->loadXML($body);
        # START XSLT
        $processor = new XsltProcessor();
        $dom_stylesheet = new DomDocument();
        $dom_stylesheet->load($_POST['stylesheet']);
        $processor->importStylesheet($dom_stylesheet);
        # PRINT
        @header("Content-Type: text/html; charset=UTF-8");
        echo $processor->transformToXml($dom_content);
    }
    if ($_POST["generate"] == "client") {
        @header("Content-Type: text/xml; charset=UTF-8");
        echo $body;
    }
    exit;
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Get Serves</title>
        <link href="stylesheet.css" rel="stylesheet" type="text/css" />
开发者ID:hannibunni,项目名称:MISHTF,代码行数:31,代码来源:getServes.php

示例12: XsltProcessor

<?php

$processor = new XsltProcessor();
$xsl = new DOMDocument();
$xsl->load("rules.xsl");
$processor->importStyleSheet($xsl);
$xml = new DomDocument();
$xml->load("feed.xml");
$result = $processor->transformToXml($xml);
echo "<pre>{$result}</pre>";
开发者ID:JohnWSteill,项目名称:EdProjs,代码行数:10,代码来源:11-15.php


注:本文中的XsltProcessor::transformToXml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。