开发者

PHP and XSLTProcessor Misbehavior

开发者 https://www.devze.com 2023-01-01 06:34 出处:网络
Simple question: Why is a PHP function called from an XSL Stylesheet just returning the last argument passed:

Simple question: Why is a PHP function called from an XSL Stylesheet just returning the last argument passed:

foo.xsl:

<xsl:templa开发者_C百科te match="/">
    <xsl:value-of select="php:function('date','c')" />
</xsl:template>

PHP:

...  
$xsl = new XSLTProcessor();
$xsl->registerPHPFunctions();
$xsl->importStylesheet($fooStylesheet);
echo $xsl->transformToXML($myXML);

I Get the output

c

and if I call <xsl:value-of select="php:function('date')" /> I just get date as my output. Seems strange to me.

Version info:

PHP 5.3.2

libxslt Version 1.1.26

libxslt compiled against libxml Version 2.7.6

EXSLT enabled

libexslt Version 1.1.26


You need the PHP xmlns in your <stylesheet> root tag:

<stylesheet xmlns:php="http://php.net/xsl">
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号