0

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

foo.xsl:

<xsl:template 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

2
  • 1
    Did you put the PHP namespace in your stylesheet root tag? Like <stylesheet xmlns:php="http://php.net/xsl"> Commented May 29, 2010 at 18:34
  • @zneak - that might help! Answer and get your +10 :) Commented May 29, 2010 at 18:37

1 Answer 1

1

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

<stylesheet xmlns:php="http://php.net/xsl">
Sign up to request clarification or add additional context in comments.

1 Comment

Fairly straight forward, but I had been starting at that stylesheet for an hour!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.