CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   Resolved Passing XSLT variables to PHP (libxslt) (http://www.codingforums.com/showthread.php?t=196209)

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?

error792 05-17-2010 03:10 AM

Resolved: http://www.exslt.org/exsl/functions/node-set/index.html


All times are GMT +1. The time now is 01:32 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.