xref: /PHP-7.2/ext/xmlreader/tests/007.phpt (revision 17ccbeec)
1--TEST--
2XMLReader: libxml2 XML Reader, setRelaxNGSchema
3--SKIPIF--
4<?php if (!extension_loaded("xmlreader")) print "skip"; ?>
5--FILE--
6<?php
7/* $Id$ */
8
9$xmlstring = '<TEI.2>hello</TEI.2>';
10$relaxngfile = dirname(__FILE__) . '/relaxNG.rng';
11$file = dirname(__FILE__) . '/_007.xml';
12file_put_contents($file, $xmlstring);
13
14$reader = new XMLReader();
15$reader->open($file);
16
17if ($reader->setRelaxNGSchema($relaxngfile)) {
18  while ($reader->read());
19}
20if ($reader->isValid()) {
21  print "file relaxNG: ok\n";
22} else {
23  print "file relaxNG: failed\n";
24}
25$reader->close();
26unlink($file);
27
28
29$reader = new XMLReader();
30$reader->XML($xmlstring);
31
32if ($reader->setRelaxNGSchema($relaxngfile)) {
33  while ($reader->read());
34}
35if ($reader->isValid()) {
36  print "string relaxNG: ok\n";
37} else {
38  print "string relaxNG: failed\n";
39}
40
41$reader->close();
42
43$reader = new XMLReader();
44$reader->XML($xmlstring);
45
46if ($reader->setRelaxNGSchema('')) {
47	echo 'failed';
48}
49$reader->close();
50?>
51===DONE===
52--EXPECTF--
53file relaxNG: ok
54string relaxNG: ok
55
56Warning: XMLReader::setRelaxNGSchema(): Schema data source is required in %s on line %d
57===DONE===
58