xslt011.phpt 1.4 KB

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