Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?
    Last edited by error792; 05-17-2010 at 04:11 AM. Reason: problem resolved

  • #2
    New Coder
    Join Date
    Jun 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •