| error792 |
05-17-2010 02:28 AM |
Passing XSLT variables to PHP (libxslt)
I have the following XML file:
Code:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<root>
hello world
</root>
and the following XSLT:
Code:
<?xml version="1.0" encoding="utf-8"?>
<stylesheet version="1.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:php="http://php.net/xsl"
extension-element-prefixes="php"
>
<template match="/root">
<variable name="node">
<element name="root">
hello world
</element>
</variable>
<value-of select="php:function(\'test\',.)"/>
<value-of select="php:function(\'test\',$node)"/>
</template>
</stylesheet>
The PHP function test is defined as
PHP Code:
function test() {
print_r(func_get_args());
}
(prints out its arguments). I expect to receive the same output from both of the bolded lines; however, the output I receive is
Code:
Array
(
[0] => Array
(
[0] => DOMElement Object
(
)
)
)
Array
(
[0] =>
hello world
)
It looks like libxslt is serializing the $node object when it passes it to PHP - how do I prevent this?
|