Annotation of embedaddon/php/ext/dom/tests/dom007.phpt, revision 1.1.1.2

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";
1.1.1.2 ! misho      66: 
        !            67: $xkeys = array();
1.1       misho      68: foreach ($ents AS $key=>$node) {
1.1.1.2 ! misho      69:        $xkeys[] = "Key: $key Name: ".$node->nodeName."\n";
        !            70: }
        !            71: sort($xkeys);  // fix inconsistent output ordering (bug #61810)
        !            72: foreach ($xkeys as $key => $node) {
        !            73:        echo $node;
1.1       misho      74: }
                     75: echo "\n";
1.1.1.2 ! misho      76: 
        !            77: $xkeys = array();
1.1       misho      78: for($x=0; $x < $length; $x++) {
1.1.1.2 ! misho      79:        $xkeys[] = "Index: ".$ents->item($x)->nodeName."\n";
        !            80: }
        !            81: sort($xkeys);  // fix inconsistent output ordering (bug #61810)
        !            82: foreach ($xkeys as $key => $node) {
        !            83:        echo $node;
1.1       misho      84: }
                     85: 
                     86: echo "\n";
                     87: $node = $ents->item(3);
                     88: var_dump($node);
                     89: $node = $ents->getNamedItem('xxx');
                     90: var_dump($node);
                     91: 
                     92: 
                     93: --EXPECT--
                     94: Length: 1
                     95: Key GIF: GIF (image/gif) (-)
                     96: 
                     97: Index 0: GIF (image/gif) (-)
                     98: 
                     99: NULL
                    100: 
                    101: Length: 3
                    102: Key: myimage Name: myimage
1.1.1.2 ! misho     103: Key: rdf Name: rdf
        !           104: Key: test Name: test
1.1       misho     105: 
1.1.1.2 ! misho     106: Index: myimage
        !           107: Index: rdf
        !           108: Index: test
1.1       misho     109: 
                    110: NULL
                    111: NULL

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>