Annotation of embedaddon/php/ext/xml/tests/xml_set_start_namespace_decl_handler_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test xml_set_start_namespace_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 : bool xml_set_start_namespace_decl_handler ( resource $parser , callback $handler )
12: * Description: Set up start namespace declaration handler.
13: * Source code: ext/xml/xml.c
14: * Alias to functions:
15: */
16:
17: $xml = <<<HERE
18: <aw1:book xmlns:aw1="http://www.somewhere.com/namespace1"
19: xmlns:aw2="file:/DTD/somewhere.dtd">
20: <aw1:para>Any old text.</aw1:para>
21: <aw2:td>An HTML table cell.</aw2:td>
22: </aw1:book>
23: HERE;
24:
25: $parser = xml_parser_create_ns();
26: xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
27:
28: var_dump(xml_set_start_namespace_decl_handler( $parser, "Namespace_Start_Handler" ));
29: var_dump(xml_set_end_namespace_decl_handler( $parser, "Namespace_End_Handler" ));
30:
31: xml_parse( $parser, $xml, true);
32: xml_parser_free( $parser );
33:
34: echo "Done\n";
35:
36: function Namespace_Start_Handler( $parser, $prefix, $uri ) {
37: echo "Namespace_Start_Handler called\n";
38: echo "...Prefix: ". $prefix . "\n";
39: echo "...Uri: ". $uri . "\n";
40: }
41:
42: function Namespace_End_Handler($parser, $prefix) {
43: echo "Namespace_End_Handler called\n";
44: echo "...Prefix: ". $prefix . "\n\n";
45: }
46:
47: function DefaultHandler( $parser, $data ) {
48: print( 'DefaultHandler Called<br/>' );
49: }
50: ?>
51: --EXPECT--
52: bool(true)
53: bool(true)
54: Namespace_Start_Handler called
55: ...Prefix: aw1
56: ...Uri: http://www.somewhere.com/namespace1
57: Namespace_Start_Handler called
58: ...Prefix: aw2
59: ...Uri: file:/DTD/somewhere.dtd
60: Done
61:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>