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


PHP XsltProcessor::importStylesheet方法代码示例

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


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

示例1: pullStats

 function pullStats($set)
 {
     $xp = new XsltProcessor();
     // create a DOM document and load the XSL stylesheet
     $xsl = new DomDocument();
     $xsl->load('stats.xslt');
     // import the XSL styelsheet into the XSLT process
     $xp->importStylesheet($xsl);
     // create a DOM document and load the XML datat
     $xml_doc = new DomDocument();
     $xml_doc->load('xmlcache/' . $set . '.xml');
     // transform the XML into HTML using the XSL file
     if ($xml = $xp->transformToXML($xml_doc)) {
         $stats_xml = simplexml_load_string($xml);
         $temp_bottom = array();
         $temp_top = array();
         foreach ($stats_xml->top as $top) {
             array_push($temp_top, (string) $top);
         }
         foreach ($stats_xml->bottom as $bottom) {
             array_push($temp_bottom, (string) $bottom);
         }
         $temp_return = array('bottom' => $temp_bottom, 'top' => $temp_top, 'total' => (string) $stats_xml->total);
         return $temp_return;
     }
 }
开发者ID:nickswalker,项目名称:thecrammer,代码行数:26,代码来源:stats.php

示例2: TeiDisplay

 public function TeiDisplay($file, array $options = array())
 {
     if ($file->getExtension() != "xml") {
         return "";
     }
     //queue_css_file('tei_display_public', 'screen', false, "plugins/TeiDisplay/views/public/css");
     //echo "<h3>displaying ", $file->original_filename, "</h3><br/>";
     $files = $file->getItem()->Files;
     foreach ($files as $f) {
         if ($f->getExtension() == "xsl") {
             $xsl_file = $f;
         }
         if ($f->getExtension() == "css") {
             $css_file = $f;
         }
     }
     //queue_css_url($css_file->getWebPath());
     echo '<link rel="stylesheet" media="screen" href="' . $css_file->getWebPath() . '"/>';
     //echo "transforming with ", $xsl_file->original_filename, "<br/>";
     $xp = new XsltProcessor();
     $xsl = new DomDocument();
     //echo "loading ", "files/original/".$xsl_file->filename, "<br/>";
     $xsl->load("files/original/" . $xsl_file->filename);
     $xp->importStylesheet($xsl);
     $xml_doc = new DomDocument();
     //echo "loading ", "files/original/".$file->filename, "<br/>";
     $xml_doc->load("files/original/" . $file->filename);
     try {
         if ($doc = $xp->transformToXML($xml_doc)) {
             return $doc;
         }
     } catch (Exception $e) {
         $this->view->error = $e->getMessage();
     }
 }
开发者ID:jmague,项目名称:TeiDisplay,代码行数:35,代码来源:TeiDisplayPlugin.php

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

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

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

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

示例7: get_document

function get_document($aNode)
{
    //get the directory in which the documents are contained from the config.php file
    global $xml_dir, $html_dir, $xslt, $html_xslt;
    //create the xslt
    $xp = new XsltProcessor();
    // create a DOM document and load the XSL stylesheet
    $xsl = new DomDocument();
    $xsl->load($xslt);
    // import the XSL styelsheet into the XSLT process
    $xp->importStylesheet($xsl);
    //open the xml document
    $xml = new DomDocument();
    $xml->loadXML($aNode);
    //transform
    if ($html = $xp->transformToXML($xml)) {
        $return = str_replace('<?xml version="1.0"?>' . "\n", "", $html);
        $return = str_replace('<!DOCTYPE div PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' . "\n", "", $return);
        $return = str_replace("\n", "", $return);
        $return = str_replace("\n ", "", $return);
        return str_replace("\t", "", $return);
    } else {
        trigger_error('XSL transformation failed.', E_USER_ERROR);
    }
}
开发者ID:QasimRiaz,项目名称:akomantoso,代码行数:25,代码来源:search.php

示例8: pubmed_metadata

function pubmed_metadata($pmid, &$item)
{
    global $debug;
    $ok = false;
    $url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?' . 'retmode=xml' . '&db=pubmed' . '&id=' . $pmid;
    //echo $url;
    $xml = get($url);
    //echo $xml;
    if (preg_match('/<\\?xml /', $xml)) {
        $ok = true;
        if ($debug) {
            echo $xml;
        }
        $dom = new DOMDocument();
        $dom->loadXML($xml);
        $xpath = new DOMXPath($dom);
        /*		$nodeCollection = $xpath->query ("//crossref/error");
        		foreach($nodeCollection as $node)
        		{
        			$ok = false;
        		}
        		if ($ok)
        		{*/
        // Get JSON
        $xp = new XsltProcessor();
        $xsl = new DomDocument();
        $xsl->load('xsl/pubmed2JSON.xsl');
        $xp->importStylesheet($xsl);
        $xml_doc = new DOMDocument();
        $xml_doc->loadXML($xml);
        $json = $xp->transformToXML($xml_doc);
        //echo $json;
        $item = json_decode($json);
        // post process
        // Ensure metadata is OK (assumes a journal for now)
        if (!isset($item->issn)) {
            $issn = '';
            if (isset($item->title)) {
                $issn = issn_from_journal_title($item->title);
            }
            if ($issn == '') {
                if (isset($item->eissn)) {
                    $issn = $item->eissn;
                }
            }
            if ($issn != '') {
                $item->issn = $issn;
            }
        }
        if ($debug) {
            echo '<h3>Boo</h3>';
            print_r($item);
        }
    }
    return $ok;
}
开发者ID:rdmpage,项目名称:bioguid,代码行数:56,代码来源:pubmed.php

示例9: evaluatePath

 /**
  * @param $path
  * @param array $data
  * @return string
  */
 protected function evaluatePath($path, array $data = [])
 {
     $preferences = $this->XSLTSimple->addChild('Preferences');
     $url = $preferences->addChild('url');
     $url->addAttribute('isHttps', Request::secure());
     $url->addAttribute('currentUrl', Request::url());
     $url->addAttribute('baseUrl', URL::to(''));
     $url->addAttribute('previousUrl', URL::previous());
     $server = $preferences->addChild('server');
     $server->addAttribute('curretnYear', date('Y'));
     $server->addAttribute('curretnMonth', date('m'));
     $server->addAttribute('curretnDay', date('d'));
     $server->addAttribute('currentDateTime', date('Y-m-d H:i:s'));
     $language = $preferences->addChild('language');
     $language->addAttribute('current', App::getLocale());
     $default_language = \Config::get('app.default_language');
     if (isset($default_language)) {
         $language->addAttribute('default', $default_language);
     }
     $languages = \Config::get('app.available_languages');
     if (is_array($languages)) {
         foreach ($languages as $lang) {
             $language->addChild('item', $lang);
         }
     }
     // from form generator
     if (isset($data['form'])) {
         $this->XSLTSimple->addChild('Form', form($data['form']));
     }
     // adding form errors to xml
     if (isset($data['errors'])) {
         $this->XSLTSimple->addData($data['errors']->all(), 'FormErrors', false);
     }
     // "barryvdh/laravel-debugbar":
     // adding XML tab
     if (true === class_exists('Debugbar')) {
         $dom = dom_import_simplexml($this->XSLTSimple)->ownerDocument;
         $dom->preserveWhiteSpace = false;
         $dom->formatOutput = true;
         $prettyXml = $dom->saveXML();
         // add new tab and append xml to it
         if (false === \Debugbar::hasCollector('XML')) {
             \Debugbar::addCollector(new \DebugBar\DataCollector\MessagesCollector('XML'));
         }
         \Debugbar::getCollector('XML')->addMessage($prettyXml, 'info', false);
     }
     $xsl_processor = new \XsltProcessor();
     $xsl_processor->registerPHPFunctions();
     $xsl_processor->importStylesheet(simplexml_load_file($path));
     return $xsl_processor->transformToXML($this->XSLTSimple);
 }
开发者ID:gulios,项目名称:xsl-laravel-template-engine,代码行数:56,代码来源:XSLTEngine.php

示例10: getInterpretedXslt

function getInterpretedXslt($xslPath, $xmlPath, $xsltProcessor = null)
{
    if ($xsltProcessor == null) {
        $xsltProcessor = new XsltProcessor();
        $xsltProcessor->registerPHPFunctions();
    }
    $xsl = new DOMDocument();
    $xsl->load($xslPath);
    $xsltProcessor->importStylesheet($xsl);
    $xml = new DOMDocument();
    $xml->load($xmlPath);
    $output = $xsltProcessor->transformToXML($xml) or die('Transformation error!');
    return $output;
}
开发者ID:CyborgOne,项目名称:cybihomecontrol_ui,代码行数:14,代码来源:xslt_functions.php

示例11: execute

 /**
  * Execute render process
  * @param string $templatePath
  * @param \DOMDocument $source
  * @param array $parameters
  * @return string
  */
 public function execute($templatePath, \DOMDocument $source, array $parameters = array())
 {
     $xsl = new \DomDocument();
     $xsl->load($templatePath);
     $processor = new \XsltProcessor();
     $processor->importStylesheet($xsl);
     $outputDom = $processor->transformToDoc($source);
     if ($parameters['output.type'] && $parameters['output.type'] == 'xml') {
         $result = $outputDom->saveXML();
     } else {
         $result = $outputDom->saveHTML();
     }
     return $result;
 }
开发者ID:kucherenko,项目名称:xsltemplate,代码行数:21,代码来源:LibXslt.php

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

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

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

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


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