xref: /PHP-5.3/ext/xsl/tests/xslt011.phpt (revision 1fa3b21c)
1--TEST--
2Test 11: php:function Support
3--SKIPIF--
4<?php require_once dirname(__FILE__) .'/skipif.inc'; ?>
5--FILE--
6<?php
7print "Test 11: php:function Support\n";
8  Class foo {
9       function foo() {}
10       function __toString() { return "not a DomNode object";}
11  }
12
13$dom = new domDocument();
14  $dom->load(dirname(__FILE__)."/xslt011.xsl");
15  $proc = new xsltprocessor;
16  $xsl = $proc->importStylesheet($dom);
17
18  $xml = new DomDocument();
19  $xml->load(dirname(__FILE__)."/xslt011.xml");
20  $proc->registerPHPFunctions();
21  print $proc->transformToXml($xml);
22
23  function foobar($id, $secondArg = "" ) {
24    if (is_array($id)) {
25        return $id[0]->value . " - " . $secondArg;
26    } else {
27        return $id . " - " . $secondArg;
28    }
29  }
30  function nodeSet($id = null) {
31      if ($id and is_array($id)) {
32          return $id[0];
33      } else {
34          $dom = new domdocument;
35          $dom->loadXML("<root>this is from an external DomDocument</root>");
36          return $dom->documentElement;
37      }
38  }
39  function nonDomNode() {
40    return  new foo();
41  }
42
43  class aClass {
44    static function aStaticFunction($id) {
45        return $id;
46    }
47  }
48
49--EXPECTF--
50Test 11: php:function Support
51
52Warning: XSLTProcessor::transformToXml(): A PHP Object cannot be converted to a XPath-string in %s on line 16
53<?xml version="1.0"?>
54foobar - secondArg
55foobar -
56this is from an external DomDocument
57from the Input Document
58static
59
60