1--TEST--
2Test xml_set_notation_decl_handler function : basic
3--SKIPIF--
4<?php
5if (!extension_loaded("xml")) {
6    print "skip - XML extension not loaded";
7}
8?>
9--FILE--
10<?php
11class XML_Parser
12{
13
14    function unparsed_entity_decl_handler($parser, $entity_name, $base, $system_ID, $public_ID, $notation_name)
15    {
16        echo "unparsed_entity_decl_handler called\n";
17        echo "...Entity name=" . $entity_name . "\n";
18        echo "...Base=" . $base . "\n";
19        echo "...System ID=" . $system_ID . "\n";
20        echo "...Public ID=" . $public_ID . "\n";
21        echo "...Notation name=" . $notation_name . "\n";
22    }
23
24    function notation_decl_handler($parser, $name, $base, $system_ID,$public_ID)
25    {
26        echo "notation_decl_handler called\n";
27        echo "...Name=" . $name . "\n";
28        echo "...Base=" . $base . "\n";
29        echo "...System ID=" . $system_ID . "\n";
30        echo "...Public ID=" . $public_ID . "\n";
31    }
32
33    function parse($data)
34    {
35        $parser = xml_parser_create();
36        xml_set_object($parser, $this);
37        xml_set_notation_decl_handler($parser, "notation_decl_handler");
38        xml_set_unparsed_entity_decl_handler($parser, "unparsed_entity_decl_handler");
39        xml_parse($parser, $data, true);
40        xml_parser_free($parser);
41    }
42}
43
44$xml = <<<HERE
45<?xml version="1.0"?>
46<!DOCTYPE dates [
47    <!NOTATION USDATE SYSTEM "http://www.schema.net/usdate.not">
48    <!NOTATION AUSDATE SYSTEM "http://www.schema.net/ausdate.not">
49    <!NOTATION ISODATE SYSTEM "http://www.schema.net/isodate.not">
50    <!ENTITY testUS  SYSTEM "test_usdate.xml" NDATA USDATE>
51    <!ENTITY testAUS SYSTEM "test_ausdate.xml" NDATA AUSDATE>
52    <!ENTITY testISO SYSTEM "test_isodate_xml" NDATA ISODATE>]>
53]>
54HERE;
55
56echo "Simple test of xml_set_notation_decl_handler(() function\n";
57$p1 = new Xml_Parser();
58$p1->parse($xml);
59echo "Done\n";
60?>
61--EXPECT--
62Simple test of xml_set_notation_decl_handler(() function
63notation_decl_handler called
64...Name=USDATE
65...Base=
66...System ID=http://www.schema.net/usdate.not
67...Public ID=
68notation_decl_handler called
69...Name=AUSDATE
70...Base=
71...System ID=http://www.schema.net/ausdate.not
72...Public ID=
73notation_decl_handler called
74...Name=ISODATE
75...Base=
76...System ID=http://www.schema.net/isodate.not
77...Public ID=
78unparsed_entity_decl_handler called
79...Entity name=testUS
80...Base=
81...System ID=test_usdate.xml
82...Public ID=
83...Notation name=USDATE
84unparsed_entity_decl_handler called
85...Entity name=testAUS
86...Base=
87...System ID=test_ausdate.xml
88...Public ID=
89...Notation name=AUSDATE
90unparsed_entity_decl_handler called
91...Entity name=testISO
92...Base=
93...System ID=test_isodate_xml
94...Public ID=
95...Notation name=ISODATE
96Done
97