Annotation of embedaddon/php/ext/dom/tests/dom007.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 7: DTD tests
3: --SKIPIF--
4: <?php
5: require_once('skipif.inc');
6: ?>
7: --FILE--
8: <?php
9: $xml = <<< EOXML
10: <?xml version="1.0" encoding="ISO-8859-1"?>
11: <!DOCTYPE courses [
12: <!ELEMENT courses (course+)>
13: <!ELEMENT course (title, description, temp*)>
14: <!ATTLIST course cid ID #REQUIRED>
15: <!ELEMENT title (#PCDATA)>
16: <!ELEMENT description (#PCDATA)>
17: <!ELEMENT temp (#PCDATA)>
18: <!ATTLIST temp vid ID #REQUIRED>
19: <!ENTITY test 'http://www.hpl.hp.com/semweb/2003/query_tester#'>
20: <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
21: <!NOTATION GIF PUBLIC "-" "image/gif">
22: <!ENTITY myimage PUBLIC "-" "mypicture.gif" NDATA GIF>
23: ]>
24: <courses>
25: <course cid="c1">
26: <title>Basic Languages</title>
27: <description>Introduction to Languages</description>
28: </course>
29: <course cid="c6">
30: <title>French I</title>
31: <description>Introduction to French</description>
32: <temp vid="c7">
33: </temp>
34: </course>
35: </courses>
36: EOXML;
37:
38: $dom = new DOMDocument();
39: $dom->loadXML($xml);
40:
41: $dtd = $dom->doctype;
42:
43: /* Notation Tests */
44: $nots = $dtd->notations;
45:
46: $length = $nots->length;
47: echo "Length: ".$length."\n";
48:
49: foreach ($nots AS $key=>$node) {
50: echo "Key $key: ".$node->nodeName." (".$node->systemId.") (".$node->publicId.")\n";
51: }
52: print "\n";
53: for($x=0; $x < $length; $x++) {
54: echo "Index $x: ".$nots->item($x)->nodeName." (".$nots->item($x)->systemId.") (".$nots->item($x)->publicId.")\n";
55: }
56:
57: echo "\n";
58: $node = $nots->getNamedItem('xxx');
59: var_dump($node);
60:
61: echo "\n";
62: /* Entity Decl Tests */
63: $ents = $dtd->entities;
64: $length = $ents->length;
65: echo "Length: ".$length."\n";
66: foreach ($ents AS $key=>$node) {
67: echo "Key: $key Name: ".$node->nodeName."\n";
68: }
69: echo "\n";
70: for($x=0; $x < $length; $x++) {
71: echo "Index $x: ".$ents->item($x)->nodeName."\n";
72: }
73:
74: echo "\n";
75: $node = $ents->item(3);
76: var_dump($node);
77: $node = $ents->getNamedItem('xxx');
78: var_dump($node);
79:
80:
81: --EXPECT--
82: Length: 1
83: Key GIF: GIF (image/gif) (-)
84:
85: Index 0: GIF (image/gif) (-)
86:
87: NULL
88:
89: Length: 3
90: Key: test Name: test
91: Key: rdf Name: rdf
92: Key: myimage Name: myimage
93:
94: Index 0: test
95: Index 1: rdf
96: Index 2: myimage
97:
98: NULL
99: NULL
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>