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


PHP XsltProcessor::setParameter方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: run

 public function run($args)
 {
     // Get variables from args array passed into detached process.
     $filepath = $args['filepath'];
     $filename = !empty($args['csv_filename']) ? $args['csv_filename'] : pathinfo($filename, PATHINFO_BASENAME);
     $format = $args['format'];
     $itemTypeId = $args['item_type_id'];
     $collectionId = $args['collection_id'];
     $createCollections = $args['create_collections'];
     $recordsArePublic = $args['public'];
     $recordsAreFeatured = $args['featured'];
     $elementsAreHtml = $args['html_elements'];
     $containsExtraData = $args['extra_data'];
     $tagName = $args['tag_name'];
     $columnDelimiter = $args['column_delimiter'];
     $enclosure = $args['enclosure'];
     $elementDelimiter = $args['element_delimiter'];
     $tagDelimiter = $args['tag_delimiter'];
     $fileDelimiter = $args['file_delimiter'];
     // TODO Intermediate stylesheets are not managed currently.
     // $stylesheetIntermediate = $args['stylesheet_intermediate'];
     $stylesheetParameters = $args['stylesheet_parameters'];
     $stylesheet = !empty($args['stylesheet']) ? $args['stylesheet'] : get_option('xml_import_xsl_directory') . DIRECTORY_SEPARATOR . get_option('xml_import_stylesheet');
     $csvfilesdir = !empty($args['destination_dir']) ? $args['destination_dir'] : sys_get_temp_dir();
     // Create a DOM document and load the XML data.
     $xml_doc = new DomDocument();
     $xml_doc->load($filepath);
     // Create a DOM document and load the XSL stylesheet.
     $xsl = new DomDocument();
     $xsl->load($stylesheet);
     // Import the XSL styelsheet into the XSLT process.
     $xp = new XsltProcessor();
     $xp->setParameter('', 'node', $tagName);
     $xp->importStylesheet($xsl);
     // Write transformed xml file to the temp csv file.
     try {
         if ($doc = $xp->transformToXML($xml_doc)) {
             $csvFilename = $csvfilesdir . DIRECTORY_SEPARATOR . pathinfo($filename, PATHINFO_FILENAME) . '.csv';
             $documentFile = fopen($csvFilename, 'w');
             fwrite($documentFile, $doc);
             fclose($documentFile);
             //$this->_initializeCsvImport($basename, $recordsArePublic, $recordsAreFeatured, $collectionId);
             $this->_helper->flashMessenger(__('Successfully generated CSV File'));
         } else {
             $this->_helper->flashMessenger(__('Could not transform XML file.  Be sure your XML document is valid.'), 'error');
         }
     } catch (Exception $e) {
         $this->view->error = $e->getMessage();
     }
 }
开发者ID:cheegunn,项目名称:XmlImport,代码行数:50,代码来源:GenerateCsv.php

示例9: createSQLScripts

function createSQLScripts()
{
    $xp = new XsltProcessor();
    // create a DOM document and load the XSL stylesheet
    $xsl = new DomDocument();
    $xsl->load($_ENV['db_xslt_create']);
    // import the XSL styelsheet into the XSLT process
    $xp->importStylesheet($xsl);
    $xp->setParameter(null, 'target', 'drop');
    // create a DOM document and load the XML datat
    $xml_doc = new DomDocument();
    $xml_doc->load($_ENV['db_xml_file']);
    // transform the XML into HTML using the XSL file
    if ($result = $xp->transformToXML($xml_doc)) {
        // save result in uninstall.sql
        $handle = fopen($_ENV['sql_script_dir'] . 'uninstall.sql', 'w');
        if (fwrite($handle, $result) === false) {
            echo 'Konnte die Datei ' . $_ENV['sql_script_dir'] . 'uninstall.sql nicht beschreiben.';
        }
        fclose($handle);
        // save result as first command in install.sql
        $handle = fopen($_ENV['sql_script_dir'] . 'install.sql', 'w');
        //if (fwrite($handle, $result) === false) {
        //  echo 'Konnte die Datei ' .$_ENV['sql_script_dir'] . 'install.sql nicht beschreiben.';
        //}
        // run the same with parameter create
        $xp->setParameter(null, 'target', 'create');
        if ($result = $xp->transformToXML($xml_doc)) {
            if (fwrite($handle, $result) === false) {
                echo 'Konnte die Datei ' . $_ENV['sql_script_dir'] . 'install.sql nicht beschreiben.';
            }
        }
        fclose($handle);
    } else {
        echo 'XSL transformation failed.';
    }
}
开发者ID:ManniManfred,项目名称:JoomlaFussballManager,代码行数:37,代码来源:make.php

示例10: translate

 /**
  * translate xml
  *
  * @param string $xml_dom 
  * @param string $xsl_dom 
  * @param string $params 
  * @param string $php_functions 
  * @return void
  * @author Andy Bennett
  */
 private static function translate($xml_dom, $xsl_dom, $params = array(), $php_functions = array())
 {
     /* create the processor and import the stylesheet */
     $proc = new XsltProcessor();
     $proc->importStyleSheet($xsl_dom);
     foreach ($params as $name => $param) {
         $proc->setParameter('', $name, $param);
     }
     if (is_array($php_functions)) {
         $proc->registerPHPFunctions($php_functions);
     }
     /* transform and output the xml document */
     $newdom = $proc->transformToDoc($xml_dom);
     return $newdom->saveXML();
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:25,代码来源:xsl.php

示例11: getReportDefinitionForm

 function getReportDefinitionForm()
 {
     $fileName = "c:/web/afids_reports/trunk/writer/xsl_templates/reportDefinition.xsl";
     $xsl = new DomDocument();
     if (!$xsl->load($fileName)) {
         echo 'failed' . $fileName;
     }
     $stylesheet = new XsltProcessor();
     $stylesheet->importStylesheet($xsl);
     // pass the report name (id) to the xsl and the filtering is done there
     $stylesheet->setParameter(null, "reportName", $this->reportName);
     if (!($translatedResponse = $stylesheet->transformToXML($this->xml_report_definition))) {
         return "error";
     } else {
         return $translatedResponse;
         //echo $translatedResponse;
     }
 }
开发者ID:yasirgit,项目名称:afids,代码行数:18,代码来源:rwEditorDatabase.php

示例12: transform

 public function transform($xsl_file = null, $xml_data = null)
 {
     CI()->benchmark->mark('xsl_transform (' . $xsl_file . ')_start');
     set_error_handler(array('XSL_Transform', 'handleError'));
     $xsl = new DOMDocument('1.0', 'UTF-8');
     $xsl->load($this->_getXSL($xsl_file));
     $inputdom = new DomDocument('1.0', 'UTF-8');
     $inputdom->loadXML($this->_getXML($xml_data));
     $proc = new XsltProcessor();
     $proc->importStylesheet($xsl);
     $proc->registerPhpFunctions($this->_allowedFunctions());
     // $result 	= $proc->transformToXML($inputdom);
     $proc->setParameter('', 'ISAJAX', CI()->is_ajax);
     $result_doc = $proc->transformToDoc($inputdom);
     $result = $result_doc->saveXML();
     restore_error_handler();
     // Strip out any <?xml stuff at top out output
     $result = preg_replace('/\\<\\?xml.+\\?\\>/', '', $result, 1);
     CI()->benchmark->mark('xsl_transform (' . $xsl_file . ')_end');
     return $result;
 }
开发者ID:vsa-partners,项目名称:typologycms,代码行数:21,代码来源:XSL_Transform.php

示例13: buildCloud

 /**
  * Retreives and formats a tag cloud for the current page.  The html
  * remains available in $this->html. If html data is already
  * present, simply returns that.
  *
  * @param $url string (Optional) The url (or id) for which a cloud should be
  * made. Default is to use the current page.
  * @param $max_tags integer  (Optional). Defaults to 0, meaning get all
  * the tags.
  *
  * @returns string The html cloud that is built. 
  */
 public function buildCloud($url = '', $max_tags = 0, $cloudtype = '')
 {
     if ($this->html) {
         return $this->html;
     }
     if (!$this->xml) {
         $this->getData($url ? $url : $this->url, $max_tags, $cloudtype);
     }
     if ($this->is_valid()) {
         $xsl = new DOMDocument();
         $xsl->load($this->loc->xsl_dir . "publiccloud.xsl");
         $proc = new XsltProcessor();
         $xsl = $proc->importStylesheet($xsl);
         // setting url format so that it is not hard coded in the xsl.
         $proc->setParameter('', 'tagviewbase', $this->loc->server_web_path . 'tagview.php?tag=');
         //using cloud->xml_DOM() because this data might have been cached already.
         $cloud = $proc->transformToDoc($this->xml_DOM());
         $this->html = $cloud->saveXML();
     }
     return $this->html;
 }
开发者ID:josf,项目名称:folkso,代码行数:33,代码来源:folksoCloud.php

示例14: fwrite

    fwrite($ob_file, $buffer);
}
// generate Core Documentation
$files = array('index', "objref", "configfiles", "scripttypes", "events", "builtintextcmds", "privileges", "attack");
foreach ($files as $f) {
    $ob_file = fopen('offline/' . $f . '.html', 'w');
    ob_start('ob_file_callback');
    require $f . '.php';
    ob_end_flush();
}
/* generate em Modules */
$xsltproc = new XsltProcessor();
$xsl = new DomDocument();
$xsl->load('escript.xslt');
$xsltproc->importStylesheet($xsl);
$xsltproc->setParameter('', 'offline', $offline);
$xml = simplexml_load_file('modules.xml');
foreach ($xml as $em) {
    $name = (string) $em['name'];
    $nicename = (string) $em['nice'];
    $ob_file = fopen('offline/' . $name . '.html', 'w');
    ob_start('ob_file_callback');
    siteheader('POL Scripting Reference ' . $nicename . '.em');
    $xml_doc = new DomDocument();
    $xml_doc->load($name . '.xml');
    if ($html = $xsltproc->transformToXML($xml_doc)) {
        echo $html;
    }
    sitefooter();
    ob_end_flush();
}
开发者ID:valterjrdev,项目名称:polserver,代码行数:31,代码来源:buildoffline.php

示例15: __process

 /**
  * Uses `DomDocument` to transform the document. Any errors that
  * occur are trapped by custom error handlers, `trapXMLError` or
  * `trapXSLError`.
  *
  * @param XsltProcessor $XSLProc
  *  An instance of `XsltProcessor`
  * @param string $xml
  *  The XML for the transformation to be applied to
  * @param string $xsl
  *  The XSL for the transformation
  * @param array $parameters
  *  An array of available parameters the XSL will have access to
  * @return string
  */
 private function __process(XsltProcessor $XSLProc, $xml, $xsl, array $parameters = array())
 {
     // Create instances of the DomDocument class
     $xmlDoc = new DomDocument();
     $xslDoc = new DomDocument();
     // Set up error handling
     if (function_exists('ini_set')) {
         $ehOLD = ini_set('html_errors', false);
     }
     // Load the xml document
     set_error_handler(array($this, 'trapXMLError'));
     // Prevent remote entities from being loaded, RE: #1939
     $elOLD = libxml_disable_entity_loader(true);
     $xmlDoc->loadXML($xml, LIBXML_NONET | LIBXML_DTDLOAD | LIBXML_DTDATTR | defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0);
     libxml_disable_entity_loader($elOLD);
     // Must restore the error handler to avoid problems
     restore_error_handler();
     // Load the xsl document
     set_error_handler(array($this, 'trapXSLError'));
     // Ensure that the XSLT can be loaded with `false`. RE: #1939
     // Note that `true` will cause `<xsl:import />` to fail.
     $elOLD = libxml_disable_entity_loader(false);
     $xslDoc->loadXML($xsl, LIBXML_NONET | LIBXML_DTDLOAD | LIBXML_DTDATTR | defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0);
     libxml_disable_entity_loader($elOLD);
     // Load the xsl template
     $XSLProc->importStyleSheet($xslDoc);
     // Set parameters when defined
     if (!empty($parameters)) {
         General::flattenArray($parameters);
         $XSLProc->setParameter('', $parameters);
     }
     // Must restore the error handler to avoid problems
     restore_error_handler();
     // Start the transformation
     set_error_handler(array($this, 'trapXMLError'));
     $processed = $XSLProc->transformToXML($xmlDoc);
     // Restore error handling
     if (function_exists('ini_set') && isset($ehOLD)) {
         ini_set('html_errors', $ehOLD);
     }
     // Must restore the error handler to avoid problems
     restore_error_handler();
     return $processed;
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:59,代码来源:class.xsltprocess.php


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