summaryrefslogtreecommitdiff
path: root/ext/xslt/tests/xslt_setopt.phpt
blob: ce45c46e1cf64e0f9642f1d2fcc2a5569c0718da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--TEST--
xslt_setopt function and public entities
--SKIPIF--
<?php
include("skipif.inc");
if(!function_exists('xslt_setopt')) {
	die("skip function xslt_setopt() is not available\n");
}
?>
--INI--
magic_quotes_runtime=0
--FILE--
<?php
error_reporting(E_ALL);
$xmlfile = dirname(__FILE__).'/public.xml';
$xslfile = dirname(__FILE__).'/args.xsl';

$xh = xslt_create();
// Tell Sablotron to process public entities
xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES);

$result = xslt_process($xh, $xmlfile, $xslfile);
print "$result\n";

$xslstring = implode('', file($xslfile));
$xslstring = str_replace('method="text"', 'method="html"', $xslstring);
$xslstring = str_replace('<xsl:value-of select="." />', '<html><head><title>foo</title></head><body><p><xsl:value-of select="." /></p></body></html>', $xslstring);
// DEBUG: print $xslstring;

xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES | XSLT_SABOPT_DISABLE_ADDING_META);
var_dump(xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslstring)));


xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES);
var_dump(xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslstring)));
// DEBUG: print "$result_meta\n";

xslt_free($xh);
?>
--EXPECT--
PHP QA®
string(95) "<html>
  <head>
    <title>foo</title>
  </head>
  <body>
    <p>PHP QA®</p>
  </body>
</html>
"
string(172) "<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>foo</title>
  </head>
  <body>
    <p>PHP QA®</p>
  </body>
</html>
"