1--TEST--
2Overriding an EXSLT builtin
3--EXTENSIONS--
4xsl
5--SKIPIF--
6<?php
7$proc = new xsltprocessor;
8if (!$proc->hasExsltSupport()) die('skip EXSLT support not available');
9if (LIBXSLT_VERSION < 10130) die('skip too old libxsl');
10require __DIR__.'/skip_upstream_issue113.inc';
11?>
12--FILE--
13<?php
14
15function dummy_year($input) {
16    var_dump($input[0]->textContent);
17    return 'dummy value';
18}
19
20function dummy_exit($input) {
21    var_dump($input);
22    exit("dummy exit");
23}
24
25$xsl = <<<XML
26<?xml version="1.0" encoding="ISO-8859-1"?>
27<xsl:stylesheet version="1.0"
28                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
29                xmlns:date="http://exslt.org/dates-and-times"
30                extension-element-prefixes="date">
31<xsl:output method="text"/>
32<xsl:template match="date"><xsl:value-of select="date:year(@date)"/></xsl:template>
33</xsl:stylesheet>
34XML;
35
36$xml = <<<XML
37<?xml version="1.0"?>
38<page><date date="2007-12-31"/></page>
39XML;
40
41$xsldoc = new DOMDocument();
42$xsldoc->loadXML($xsl);
43
44$xmldoc = new DOMDocument();
45$xmldoc->loadXML($xml);
46
47$proc = new XSLTProcessor();
48$proc->importStylesheet($xsldoc);
49
50// Should override the builtin function
51$proc->registerPHPFunctionNS('http://exslt.org/dates-and-times', 'year', dummy_year(...));
52echo $proc->transformToXML($xmldoc), "\n";
53
54// Should not exit
55$proc->registerPHPFunctionNS('http://www.w3.org/1999/XSL/Transform', 'value-of', dummy_exit(...));
56echo $proc->transformToXML($xmldoc), "\n";
57
58?>
59--EXPECT--
60string(10) "2007-12-31"
61dummy value
62string(10) "2007-12-31"
63dummy value
64