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


PHP XsltProcessor::registerPhpFunctions方法代码示例

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


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

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

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

示例3: 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);
     // http://www.php.net/manual/en/xsltprocessor.transformtoxml.php#62081
     //$result = $proc->transformToDoc($inputdom);
     //$result = $result->saveHTML();
     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

示例4: transform

 static function transform($xsl_file, $xml, $params = null, $charset = 'UTF-8', $nohead = false)
 {
     global $o_global;
     $ent = '<!DOCTYPE page [
     <!ENTITY nbsp   "&#160;">
     <!ENTITY copy   "&#169;">
     <!ENTITY reg    "&#174;">
     <!ENTITY trade  "&#8482;">
     <!ENTITY mdash  "&#8212;">
     <!ENTITY ldquo  "&#0171;">
     <!ENTITY rdquo  "&#0187;">
     <!ENTITY pound  "&#163;">
     <!ENTITY sum    "&#0216;">
     <!ENTITY yen    "&#165;">
     <!ENTITY euro   "&#8364;">
 ]>';
     if (!$nohead) {
         $xml = "<?xml version=\"1.0\" encoding=\"" . $charset . "\"?>\n" . $ent . $xml;
     }
     $browser = null;
     if (empty($xml)) {
         $xml = '<empty_xml>Empty xml</empty_xml>';
     }
     //$xml=iconv('cp1251','cp1251',$xml);
     if (!$nohead && $charset == 'windows-1251') {
         $xml = preg_replace("{[�]}i", "", $xml);
     }
     $xsl = new DomDocument();
     //$xsl->resolveExternals = true;
     $xsl->substituteEntities = true;
     if (file_exists($o_global->themes_site_root . $xsl_file)) {
         $xsl->load($o_global->themes_site_root . $xsl_file);
     } elseif (file_exists($o_global->themes_engine_root . $xsl_file)) {
         $xsl->load($o_global->themes_engine_root . $xsl_file);
     } elseif (_GL_DEBUG === true) {
         return 'Function "transform". Error. File "' . $xsl_file . '" not found (' . $o_global->themes_site_root . $xsl_file . ', ' . $o_global->themes_engine_root . $xsl_file . ')<BR/>' . "\n";
     } else {
         return '';
     }
     //$inputdom = new DomDocument();
     //$inputdom->loadXML($xml);
     /* create the processor and import the stylesheet */
     $proc = new XsltProcessor();
     $proc->registerPhpFunctions();
     //$xsl = $proc->importStylesheet($xsl);
     if ($params) {
         foreach ($params as $key => $value) {
             $proc->setParameter(null, $key, $value);
         }
     }
     $inputdom = new DomDocument();
     $inputdom->substituteEntities = true;
     $inputdom->loadXML($xml);
     $proc->importStyleSheet($xsl);
     $res = $proc->transformToXML($inputdom);
     return $res;
 }
开发者ID:Rabotyahoff,项目名称:xml_engine,代码行数:57,代码来源:c_xml.php

示例5: __autoload

<?php

function __autoload($className)
{
    var_dump($className);
    exit;
}
$xsl = new DomDocument();
$xsl->loadXML('<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl">
<xsl:template match="/">
<xsl:value-of select="php:function(\'TeSt::dateLang\')" />
</xsl:template>
</xsl:stylesheet>');
$inputdom = new DomDocument();
$inputdom->loadXML('<?xml version="1.0" encoding="iso-8859-1" ?>
<today></today>');
$proc = new XsltProcessor();
$proc->registerPhpFunctions();
$xsl = $proc->importStylesheet($xsl);
$newdom = $proc->transformToDoc($inputdom);
?>
===DONE===
开发者ID:badlamer,项目名称:hhvm,代码行数:25,代码来源:bug33853.php


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