• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP xslt_set_encoding函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: perform_xslt

function perform_xslt($xml, $s, $islast, $isfirst, $param_path)
{
    global $base_path, $charset;
    $transform = "{$base_path}/admin/convert/imports/" . $param_path . "/" . $s['XSLFILE'][0]['value'];
    //Si c'est la première transformation, on rajoute les entêtes
    if ($isfirst) {
        if ($s['ENCODING']) {
            $xml1 = "<?xml version=\"1.0\" encoding=\"" . $s['ENCODING'] . "\"?>\n<" . $s['ROOTELEMENT'][0]["value"];
        } else {
            $xml1 = "<?xml version=\"1.0\" encoding=\"{$charset}\"?>\n<" . $s['ROOTELEMENT'][0]["value"];
        }
        if ($s["NAMESPACE"]) {
            $xml1 .= " xmlns:" . $s["NAMESPACE"][0]["ID"] . "='" . $s["NAMESPACE"][0]["value"] . "' ";
        }
        $xml1 .= ">\n" . $xml . "\n</" . $s['ROOTELEMENT'][0]['value'] . ">";
        $xml = $xml1;
    }
    $f = fopen($transform, "r");
    $xsl = fread($f, filesize($transform));
    fclose($f);
    //Création du processeur
    $xh = xslt_create();
    //Encodage = $charset
    if (defined("ICONV_IMPL")) {
        xslt_set_encoding($xh, "{$charset}");
    }
    // Traite le document
    if ($result = @xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, array("/_xml" => $xml, "/_xsl" => $xsl))) {
        $r['VALID'] = true;
        $r['DATA'] = $result;
        $r['ERROR'] = "";
        //Si c'est la dernière transformation, on supprime les entêtes et l'élément root
        if ($islast) {
            $p = preg_match("/<" . $s['TNOTICEELEMENT'][0]['value'] . "(?:\\ [^>]*|)>/", $r["DATA"], $m, PREG_OFFSET_CAPTURE);
            if ($p) {
                $r['DATA'] = "  " . substr($r['DATA'], $m[0][1]);
            }
            $p1 = 0;
            $p = 0;
            while ($p !== false) {
                $p1 = $p;
                $p = @strpos($r['DATA'], "</" . $s['TNOTICEELEMENT'][0]['value'] . ">", $p1 + strlen("</" . $s['TNOTICEELEMENT'][0]['value'] . ">"));
            }
            if ($p1 !== false && $p1 != 0) {
                $r['DATA'] = substr($r['DATA'], 0, $p1 + strlen($s['TNOTICEELEMENT'][0]['value']) + 3) . "\n";
            }
        }
    } else {
        $r['VALID'] = false;
        $r['DATA'] = "";
        $r['ERROR'] = "Sorry, notice could not be transformed by {$transform} the reason is that " . xslt_error($xh) . " and the error code is " . xslt_errno($xh);
    }
    xslt_free($xh);
    return $r;
}
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:55,代码来源:xmltransform.php


示例2: output

function output($output)
{
    /* Falls die Seite als HTML ausgegeben werden soll */
    /* Eine Weiche einbauen, fals die XSLT Extension nicht geladen ist -> 
       http://koders.com/php/fidB0434D36F01703F9ACAB5E21065E315FE44D2C57.aspx?s=xslt_process
       http://koders.com/php/fid78371B5F37DAE258E3258B91CC791A712CBF2AAC.aspx?s=xslt_process
       */
    if (isset($_SESSION['variables']['extention']) and $_SESSION['variables']['extention'] == "html" and IS_XSLT) {
        if (version_compare(phpversion(), "5.0", ">")) {
            $processor = new XSLTProcessor();
            $xmlDom = new DOMDocument();
            $xslDom = new DOMDocument();
            $xmlDom->loadXML($output);
            $xslDom->load(BIN_DIR . "xslt/index.xsl");
            $processor->importstylesheet($xslDom);
            /* Transformiert den Output
               :TODO: Fehlerabfrage der Resultates
               :ATTENTION: eventuell werden die im XSL-File includeten Dateien falsch eingebunden*/
            $result = $processor->transformtoxml($xmlDom);
        } else {
            /* PHP4 XSLT Prozessor, ist auch unter PHP5 erreichbar, nur langsamer */
            /* XSL File auslesen und Content ueberschreiben */
            $filename = "xslt/main.xsl";
            $handle = fopen($filename, "r");
            $xsl_contents = fread($handle, filesize($filename));
            fclose($handle);
            /* :TODO: Anpassen des xsc fuer die Uebergabe des Templatefiles */
            // $xsl = sprintf($xsl_contents, $_SESSION['variables']['template_content']);
            $xsl = $xsl_contents;
            /* Stylesheet uebergeben */
            $processor_arguments = array('/_xml' => $output, '/_xsl' => $xsl);
            $processor = xslt_create();
            xslt_set_encoding($processor, 'ISO-8859-1');
            xslt_set_base($processor, 'file://' . BIN_DIR . 'xslt/');
            /* Transformiert den Output */
            $result = xslt_process($processor, 'arg:/_xml', 'arg:/_xsl', NULL, $processor_arguments);
            if (!$result && xslt_errno($processor) > 0) {
                $result = sprintf("Kann XSLT Dokument nicht umarbeiten [%d]: %s", xslt_errno($processor), xslt_error($processor));
            }
            xslt_free($processor);
        }
        /* Gibt das HTML-Dokument aus */
        echo $result;
    } else {
        header("Content-Type: text/xml");
        echo $output;
    }
}
开发者ID:BackupTheBerlios,项目名称:urulu-svn,代码行数:48,代码来源:output.php


示例3: do_transformation

function do_transformation($xml, $xsl, &$result, $option)
{
    if ($option == 'xml') {
        header("Content-type: application/xml");
        $result = $xml;
        return 1;
    } else {
        if ($option == 'xsl') {
            /**
             * Compatibility function wrappers. These are function's wrappers that make
             * available functions found on newer PHP versions (mostly 4.3 ones).
             */
            $version = explode(".", phpversion());
            $major = $version[0];
            $minor = $version[1];
            $release = $version[2];
            if ($major >= 5) {
                $xmlDOM = new DomDocument();
                $xslDOM = new DomDocument();
                $xsltEngine = new XsltProcessor();
                $xmlDOM->loadXML($xml);
                $xslDOM->load($xsl);
                $xsltEngine->importStylesheet($xslDOM);
                $transformation = $xsltEngine->transformToXml($xmlDOM);
                echo $transformation;
                return 1;
            } else {
                $xsl_proc = xslt_create();
                xslt_set_encoding($xsl_proc, "ISO-8859-1");
                $arg = array('/_xml' => $xml);
                $result = xslt_process($xsl_proc, $xml, $xsl, NULL, $arg);
                xslt_free($xsl_proc);
                return 1;
            }
        } else {
            return 0;
        }
    }
}
开发者ID:magsilva,项目名称:NoRiskPlanning,代码行数:39,代码来源:xsl_handler.php


示例4: xslt_create

 /**
  * Use PHP4's xslt extension to do the XSL transformation
  * @param $xml mixed
  * @param $xmlType integer
  * @param $xsl mixed
  * @param $xslType integer
  * @param $resultType integer
  * @return string return type for PHP4 is always string or "false" on error.
  */
 function &_transformPHP4(&$xml, $xmlType, &$xsl, $xslType, $resultType)
 {
     $falseVar = false;
     // PHP4 doesn't support DOM
     if ($xmlType == XSL_TRANSFORMER_DOCTYPE_DOM || $xslType == XSL_TRANSFORMER_DOCTYPE_DOM || $resultType == XSL_TRANSFORMER_DOCTYPE_DOM) {
         return $falseVar;
     }
     // Create the processor
     $processor = xslt_create();
     xslt_set_encoding($processor, XSLT_PROCESSOR_ENCODING);
     // Create arguments for string types (if any)
     $arguments = array();
     if ($xmlType == XSL_TRANSFORMER_DOCTYPE_STRING) {
         $arguments['/_xml'] = $xml;
         $xml = 'arg:/_xml';
     }
     if ($xslType == XSL_TRANSFORMER_DOCTYPE_STRING) {
         $arguments['/_xsl'] = $xsl;
         $xsl = 'arg:/_xsl';
     }
     if (empty($arguments)) {
         $arguments = null;
     }
     // Do the transformation
     $resultXML = xslt_process($processor, $xml, $xsl, null, $arguments, $this->parameters);
     // Error handling
     if (!$resultXML) {
         $this->addError("Cannot process XSLT document [%d]: %s", xslt_errno($processor), xslt_error($processor));
         return $falseVar;
     }
     // DOM is not supported in PHP4 so we can always directly return the string result
     return $resultXML;
 }
开发者ID:anorton,项目名称:pkp-lib,代码行数:42,代码来源:XSLTransformer.inc.php


示例5: apply_xsl_to_xml

 function apply_xsl_to_xml($xml, $xsl)
 {
     global $charset;
     $xh = xslt_create();
     xslt_set_encoding($xh, $charset);
     $arguments = array('/_xml' => $xml, '/_xsl' => $xsl);
     $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
     xslt_free($xh);
     return $result;
 }
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:10,代码来源:cfile.class.php


示例6: to_unimarc

 function to_unimarc($metatdata)
 {
     //$xsl=file_get_contents("/home/ftetart/public_html/php_dev/admin/connecteurs/in/oai/dc2uni.xsl");
     /* Allocation du processeur XSLT */
     $xh = xslt_create();
     xslt_set_encoding($xh, $this->charset);
     $notice = "<?xml version='1.0' encoding='" . $this->charset . "'?>\n" . $metatdata;
     /* Traitement du document */
     $arguments = array('/_xml' => $notice, '/_xsl' => $this->xslt_transform);
     $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
     return $result;
 }
开发者ID:noble82,项目名称:proyectos-ULS,代码行数:12,代码来源:oai_protocol.class.php


示例7: record_to_xml_unimarc

 function record_to_xml_unimarc($record, $style_sheets, $charset)
 {
     global $xslt_base_path;
     global $debug;
     if ($debug) {
         highlight_string(print_r($record, true));
     }
     //		file_put_contents('dublincoreextended1.xml', $record);
     $xh = xslt_create();
     //		echo $charset;
     xslt_set_encoding($xh, $charset);
     $result = $record;
     foreach ($style_sheets as $style_sheet) {
         if ($debug) {
             echo '<h3>' . $style_sheet . '</h3>';
         }
         /* Traitement du document */
         $arguments = array('/_xml' => $result, '/_xsl' => $style_sheet);
         $result = xslt_process($xh, 'arg:/_xml', 'arg:/_xsl', NULL, $arguments);
         if ($debug) {
             highlight_string(print_r($result, true));
         }
         if (!$result) {
             $this->error = true;
             $this->error_message = "Sorry, notice could not be transformed by {$style_sheet} the reason is that " . xslt_error($xh) . " and the error code is " . xslt_errno($xh);
         }
     }
     xslt_free($xh);
     return $result;
 }
开发者ID:hogsim,项目名称:PMB,代码行数:30,代码来源:sru_protocol.class.php


示例8: htmlspecialchars

if (!$xslt) {
    print "<div class='error'>No XSLT processor defined !</div>";
}
print "<h1>" . htmlspecialchars($title) . "</h1>\n";
?>
 <script type='text/javascript'>
 id_pool=<?php 
echo $id_pool;
?>
;
 <? if ($todojs) print "$todojs);"; else print "todo = new Array();"; ?>
 </script>
<?

print "<div class='inex'>";
xslt_set_encoding($xslt,"UTF-8");

// Has no cache
 if (!is_file($xmlfilename)) print "<div>$xmlfilename is not a valid file ?</div>\n";
if (!is_dir("$xml_cache/$path")) {

  $result = xslt_process($xslt,$xmlfilename,"$xslfilename")  ;
   if ($result) {
//     print "<div class='warning'>No cache directory was found</div>\n";
      eval("?>" . $result . "<?");
   } else {
      exit("xslt error: " . xslt_error($xslt));
   }
}

// We do have cache
开发者ID:BackupTheBerlios,项目名称:x-rai-svn,代码行数:31,代码来源:collections.php


示例9: array

<?php

$x_args = array('_xml' => $xml, '_xsl' => $xsl, '_result' => $result);
/* Reports suggest that xslt_process won't work with NULL param list */
$x_params = array('_param' => $params);
$ssheet = xslt_create();
xslt_set_encoding($ssheet, "UTF-8");
/* xslt logging options */
xslt_set_log($ssheet, 4);
xslt_set_log($ssheet, "/tmp/xslt.err");
/* Now generate the XML output file */
$xml_file = "form1.xml";
$result = xslt_process($ssheet, $xml_file, 'admin_topic.xslt', NULL, $x_args, $x_params);
print $result;
xslt_free($ssheet);
开发者ID:slugbucket,项目名称:jrform,代码行数:15,代码来源:show_xml_form.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP xslt_set_error_handler函数代码示例发布时间:2022-05-23
下一篇:
PHP xslt_process函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap