Skip to content

Commit 48bcd44

Browse files
committed
Add additional test
1 parent ce5ab06 commit 48bcd44

File tree

1 file changed

+62
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)