2002-10-25 19:17:16 +00:00
|
|
|
|
--TEST--
|
2002-10-31 21:11:57 +00:00
|
|
|
|
xslt_setopt function and public entities
|
2002-10-25 19:17:16 +00:00
|
|
|
|
--SKIPIF--
|
|
|
|
|
<?php
|
|
|
|
|
include("skipif.inc");
|
|
|
|
|
if(!function_exists('xslt_setopt')) {
|
2002-10-29 21:57:51 +00:00
|
|
|
|
die("skip function xslt_setopt() is not available\n");
|
2002-10-25 19:17:16 +00:00
|
|
|
|
}
|
|
|
|
|
?>
|
2002-10-29 21:57:51 +00:00
|
|
|
|
--INI--
|
|
|
|
|
magic_quotes_runtime=0
|
2002-10-25 19:17:16 +00:00
|
|
|
|
--FILE--
|
|
|
|
|
<?php
|
|
|
|
|
error_reporting(E_ALL);
|
2002-10-29 21:57:51 +00:00
|
|
|
|
$xmlfile = dirname(__FILE__).'/public.xml';
|
|
|
|
|
$xslfile = dirname(__FILE__).'/args.xsl';
|
2002-10-25 19:17:16 +00:00
|
|
|
|
|
|
|
|
|
$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);
|
2002-10-29 21:57:51 +00:00
|
|
|
|
var_dump(xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslstring)));
|
|
|
|
|
|
2002-10-25 19:17:16 +00:00
|
|
|
|
|
|
|
|
|
xslt_setopt($xh, XSLT_SABOPT_PARSE_PUBLIC_ENTITIES);
|
2002-10-29 21:57:51 +00:00
|
|
|
|
var_dump(xslt_process($xh, $xmlfile, 'arg:/_xsl', NULL, array('/_xsl' => $xslstring)));
|
2002-10-25 19:17:16 +00:00
|
|
|
|
// DEBUG: print "$result_meta\n";
|
|
|
|
|
|
|
|
|
|
xslt_free($xh);
|
|
|
|
|
?>
|
|
|
|
|
--EXPECT--
|
|
|
|
|
PHP QA<51>
|
2002-10-29 21:57:51 +00:00
|
|
|
|
string(95) "<html>
|
|
|
|
|
<head>
|
|
|
|
|
<title>foo</title>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<p>PHP QA<51></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<51></p>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
2002-10-31 21:11:57 +00:00
|
|
|
|
"
|