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


PHP XSLTProcessor::setSecurityPrefs方法代码示例

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


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

示例1: applyXslt

 /**
  * @param string $inFile
  * @param string $xssFile
  * @param string $outFileOrDir
  * @throws \Exception
  */
 public static function applyXslt($inFile, $xssFile, $outFileOrDir)
 {
     if (!file_exists($inFile)) {
         throw new \Exception("File {$inFile} cannot be found");
     }
     if (!file_exists($xssFile)) {
         throw new \Exception("File {$xssFile} cannot be found");
     }
     // Load the XML source
     $xml = new \DOMDocument();
     $xml->load($inFile);
     $xsl = new \DOMDocument();
     $xsl->load($xssFile);
     // Configure the transformer
     $processor = new \XSLTProcessor();
     if (version_compare(PHP_VERSION, '5.4', "<")) {
         if (defined('XSL_SECPREF_WRITE_FILE')) {
             ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
         }
     } else {
         // the php online docs only mention setSecurityPrefs, but somehow some installs have setSecurityPreferences...
         if (method_exists('XSLTProcessor', 'setSecurityPrefs')) {
             $processor->setSecurityPrefs(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
         } else {
             $processor->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE);
         }
     }
     $processor->importStyleSheet($xsl);
     // attach the xsl rules
     if (is_dir($outFileOrDir)) {
         if (!$processor->setParameter('', 'base.dir', realpath($outFileOrDir))) {
             echo "setting param base.dir KO\n";
         }
     }
     $out = $processor->transformToXML($xml);
     if (!is_dir($outFileOrDir)) {
         file_put_contents($outFileOrDir, $out);
     }
 }
开发者ID:shahzadsab,项目名称:phpxmlrpc,代码行数:45,代码来源:pakefile.php

示例2: transform

 /**
  * Transforms the DOM document
  */
 protected function transform(DOMDocument $document)
 {
     if (!$this->toDir->exists()) {
         throw new BuildException("Directory '" . $this->toDir . "' does not exist");
     }
     $xslfile = $this->getStyleSheet();
     $xsl = new DOMDocument();
     $xsl->load($xslfile->getAbsolutePath());
     $proc = new XSLTProcessor();
     if (defined('XSL_SECPREF_WRITE_FILE')) {
         if (version_compare(PHP_VERSION, '5.4', "<")) {
             ini_set("xsl.security_prefs", XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
         } else {
             $proc->setSecurityPrefs(XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
         }
     }
     $proc->importStyleSheet($xsl);
     $proc->setParameter('', 'output.sorttable', $this->useSortTable);
     if ($this->format == "noframes") {
         $writer = new FileWriter(new PhingFile($this->toDir, "phpunit-noframes.html"));
         $writer->write($proc->transformToXML($document));
         $writer->close();
     } else {
         ExtendedFileStream::registerStream();
         $toDir = (string) $this->toDir;
         // urlencode() the path if we're on Windows
         if (FileSystem::getFileSystem()->getSeparator() == '\\') {
             $toDir = urlencode($toDir);
         }
         // no output for the framed report
         // it's all done by extension...
         $proc->setParameter('', 'output.dir', $toDir);
         $proc->transformToXML($document);
         ExtendedFileStream::unregisterStream();
     }
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:39,代码来源:PHPUnitReportTask.php

示例3: process

 /**
  * Try to process the XSLT transformation
  *
  * @param   string  XML to process.
  * @param   string  XSLT sheet to use for the processing.
  *
  * @throws BuildException   On XSLT errors
  */
 protected function process($xml, $xsl)
 {
     $processor = new XSLTProcessor();
     // Create and setup document.
     $xmlDom = new DOMDocument();
     $xmlDom->resolveExternals = $this->resolveDocumentExternals;
     // Create and setup stylesheet.
     $xslDom = new DOMDocument();
     $xslDom->resolveExternals = $this->resolveStylesheetExternals;
     if ($this->html) {
         $xmlDom->loadHTML($xml);
     } else {
         $xmlDom->loadXML($xml);
     }
     $xslDom->loadxml($xsl);
     if (defined('XSL_SECPREF_WRITE_FILE')) {
         if (version_compare(PHP_VERSION, '5.4', "<")) {
             ini_set("xsl.security_prefs", XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
         } else {
             $processor->setSecurityPrefs(XSL_SECPREF_WRITE_FILE | XSL_SECPREF_CREATE_DIRECTORY);
         }
     }
     $processor->importStylesheet($xslDom);
     // ignoring param "type" attrib, because
     // we're only supporting direct XSL params right now
     foreach ($this->xsltParams as $param) {
         $this->log("Setting XSLT param: " . $param->getName() . "=>" . $param->getExpression(), Project::MSG_DEBUG);
         $processor->setParameter(null, $param->getName(), $param->getExpression());
     }
     $errorlevel = error_reporting();
     error_reporting($errorlevel & ~E_WARNING);
     @($result = $processor->transformToXML($xmlDom));
     error_reporting($errorlevel);
     if (false === $result) {
         //$errno = xslt_errno($processor);
         //$err   = xslt_error($processor);
         throw new BuildException("XSLT Error");
     } else {
         return $result;
     }
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:49,代码来源:XsltFilter.php


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