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


PHP xslt_set_error_handler函数代码示例

本文整理汇总了PHP中xslt_set_error_handler函数的典型用法代码示例。如果您正苦于以下问题:PHP xslt_set_error_handler函数的具体用法?PHP xslt_set_error_handler怎么用?PHP xslt_set_error_handler使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _generateReport

 function _generateReport($xmlFile, $php, $env)
 {
     if (version_compare(PHP_VERSION, '5', '>=') && extension_loaded('xsl')) {
         $this->debug('Including php5 xslt wrapper');
         require_once AK_BASE_DIR . DS . 'vendor' . DS . 'xslt-php4-php5' . DS . 'xslt-php4-php5.php';
     }
     // Fail if XSLT extension is not available
     if (!function_exists('xslt_create')) {
         $this->error('Cannot generate report: xslt extension missing');
         return FALSE;
     }
     $currentDir = getcwd();
     chdir(AK_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'xsl');
     $xsl_file = AK_BASE_DIR . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'xsl' . DIRECTORY_SEPARATOR . 'phpunit2-noframes.xsl';
     // look for xsl
     if (!is_readable($xsl_file)) {
         $this->error('Cannot generate report: ' . $xsl_file . ' missing');
         chdir($currentDir);
         return FALSE;
     }
     if (!is_readable($xmlFile)) {
         return false;
     }
     $schema = file_get_contents($xmlFile);
     $xml = new SimpleXMLElement($schema);
     $suites = $xml->xpath("/testsuites/testsuite");
     $tests = 0;
     $failures = 0;
     $errors = 0;
     $time = 0;
     foreach ($suites as $suite) {
         $attributes = $suite->attributes();
         $tests += (int) $attributes->tests;
         $failures += (int) $attributes->failures;
         $errors += (int) $attributes->errors;
         $time += (double) $attributes->time;
     }
     $environment = array();
     $environment['php'] = $php;
     $environment['class'] = $failures > 0 ? 'failure' : $errors > 0 ? 'error' : '';
     $environment['backend'] = $env;
     $environment['tests'] = $tests;
     $environment['failures'] = $failures;
     $environment['errors'] = $errors;
     $environment['time'] = round($time, 3);
     $link = AK_BASE_DIR . DS . 'test' . DS . 'report' . DS . $php . DS . $env . DS . 'index.html';
     $environment['details'] = 'file://' . $link;
     $this->report_environments[] = $environment;
     $arguments = array('/_xml' => $schema, '/_xsl' => file_get_contents($xsl_file));
     // create an XSLT processor
     $xh = xslt_create();
     // set error handler
     xslt_set_error_handler($xh, array(&$this, 'xslt_error_handler'));
     // process the schema
     $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
     xslt_free($xh);
     $targetFile = AK_BASE_DIR . DS . 'test' . DS . 'report' . DS . $php . DS . $env . DS . 'index.html';
     if (!file_exists(dirname($targetFile))) {
         mkdir(dirname($targetFile), 0777, true);
     }
     file_put_contents($targetFile, $result);
     chdir($currentDir);
 }
开发者ID:joeymetal,项目名称:v1,代码行数:63,代码来源:ci-test.php

示例2: TransformSchema

 function TransformSchema($schema, $xsl, $schematype = 'string')
 {
     // Fail if XSLT extension is not available
     if (!function_exists('xslt_create')) {
         return FALSE;
     }
     $xsl_file = dirname(__FILE__) . '/xsl/' . $xsl . '.xsl';
     // look for xsl
     if (!is_readable($xsl_file)) {
         return FALSE;
     }
     switch ($schematype) {
         case 'file':
             if (!is_readable($schema)) {
                 return FALSE;
             }
             $schema = _file_get_contents($schema);
             break;
         case 'string':
         default:
             if (!is_string($schema)) {
                 return FALSE;
             }
     }
     $arguments = array('/_xml' => $schema, '/_xsl' => _file_get_contents($xsl_file));
     // create an XSLT processor
     $xh = xslt_create();
     // set error handler
     xslt_set_error_handler($xh, array(&$this, 'xslt_error_handler'));
     // process the schema
     $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
     xslt_free($xh);
     return $result;
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:34,代码来源:adodb-xmlschema.inc.php

示例3: ConvertSchemaFile

 /**
  * Converts an XML schema file to the specified DTD version.
  *
  * Call this method to convert the specified XML schema file to a different AXMLS
  * DTD version. For instance, to convert a schema created for an pre-1.0 version for 
  * AXMLS (DTD version 0.1) to a newer version of the DTD (e.g. 0.2). If no DTD version 
  * parameter is specified, the schema will be converted to the current DTD version. 
  * If the newFile parameter is provided, the converted schema will be written to the specified
  * file.
  * @see ConvertSchemaString()
  *
  * @param string $filename Name of XML schema file that will be converted.
  * @param string $newVersion DTD version to convert to.
  * @param string $newFile File name of (converted) output file.
  * @return string Converted XML schema or FALSE if an error occurs.
  */
 function ConvertSchemaFile($filename, $newVersion = NULL, $newFile = NULL)
 {
     // grab current version
     if (!($version = $this->SchemaFileVersion($filename))) {
         return FALSE;
     }
     if (!isset($newVersion)) {
         $newVersion = $this->schemaVersion;
     }
     if ($version == $newVersion) {
         $result = file_get_contents($filename);
         // remove unicode BOM if present
         if (substr($result, 0, 3) == sprintf('%c%c%c', 239, 187, 191)) {
             $result = substr($result, 3);
         }
     } else {
         // Fail if XSLT extension is not available
         if (!function_exists('xslt_create')) {
             return FALSE;
         }
         $xsl_file = dirname(__FILE__) . '/xsl/convert-' . $version . '-' . $newVersion . '.xsl';
         // look for xsl
         if (!is_readable($xsl_file)) {
             return FALSE;
         }
         $arguments = array('/_xml' => file_get_contents($filename), '/_xsl' => file_get_contents($xsl_file));
         // create an XSLT processor
         $xh = xslt_create();
         // set error handler
         xslt_set_error_handler($xh, array(&$this, 'xslt_error_handler'));
         // process the schema
         $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
         xslt_free($xh);
     }
     if (is_string($newFile) and $fp = fopen($newFile, 'w')) {
         fwrite($fp, $result);
         fclose($fp);
     }
     return $result;
 }
开发者ID:BackupTheBerlios,项目名称:facturaphp-svn,代码行数:56,代码来源:adodb-xmlschema.inc.php


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