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