rrichards               Thu Oct  5 11:59:43 2006 UTC

  Added files:                 
    /php-src/ext/dom/tests      domdocument.phpt 

  Modified files:              
    /php-src/ext/dom    document.c 
  Log:
  mark functions unicode compliant
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/document.c?r1=1.80&r2=1.81&diff_format=u
Index: php-src/ext/dom/document.c
diff -u php-src/ext/dom/document.c:1.80 php-src/ext/dom/document.c:1.81
--- php-src/ext/dom/document.c:1.80     Sat Sep 16 19:08:59 2006
+++ php-src/ext/dom/document.c  Thu Oct  5 11:59:42 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: document.c,v 1.80 2006/09/16 19:08:59 iliaa Exp $ */
+/* $Id: document.c,v 1.81 2006/10/05 11:59:42 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -761,7 +761,7 @@
 
 
 
-/* {{{ proto DOMElement dom_document_create_element(string tagName [, string 
value]);
+/* {{{ proto DOMElement dom_document_create_element(string tagName [, string 
value]) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-2141741547
 Since: 
 */
@@ -795,7 +795,7 @@
 /* }}} end dom_document_create_element */
 
 
-/* {{{ proto DOMDocumentFragment dom_document_create_document_fragment();
+/* {{{ proto DOMDocumentFragment dom_document_create_document_fragment() U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-35CB04B5
 Since: 
 */
@@ -823,7 +823,7 @@
 /* }}} end dom_document_create_document_fragment */
 
 
-/* {{{ proto DOMText dom_document_create_text_node(string data);
+/* {{{ proto DOMText dom_document_create_text_node(string data) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1975348127
 Since: 
 */
@@ -852,7 +852,7 @@
 /* }}} end dom_document_create_text_node */
 
 
-/* {{{ proto DOMComment dom_document_create_comment(string data);
+/* {{{ proto DOMComment dom_document_create_comment(string data) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1334481328
 Since: 
 */
@@ -881,7 +881,7 @@
 /* }}} end dom_document_create_comment */
 
 
-/* {{{ proto DOMCdataSection dom_document_create_cdatasection(string data);
+/* {{{ proto DOMCdataSection dom_document_create_cdatasection(string data) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-D26C0AF8
 Since: 
 */
@@ -910,7 +910,7 @@
 /* }}} end dom_document_create_cdatasection */
 
 
-/* {{{ proto DOMProcessingInstruction 
dom_document_create_processing_instruction(string target, string data);
+/* {{{ proto DOMProcessingInstruction 
dom_document_create_processing_instruction(string target, string data) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-135944439
 Since: 
 */
@@ -946,7 +946,7 @@
 /* }}} end dom_document_create_processing_instruction */
 
 
-/* {{{ proto DOMAttr dom_document_create_attribute(string name);
+/* {{{ proto DOMAttr dom_document_create_attribute(string name) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-1084891198
 Since: 
 */
@@ -981,7 +981,7 @@
 /* }}} end dom_document_create_attribute */
 
 
-/* {{{ proto DOMEntityReference dom_document_create_entity_reference(string 
name);
+/* {{{ proto DOMEntityReference dom_document_create_entity_reference(string 
name) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-392B75AE
 Since: 
 */
@@ -1015,7 +1015,7 @@
 /* }}} end dom_document_create_entity_reference */
 
 
-/* {{{ proto DOMNodeList dom_document_get_elements_by_tag_name(string tagname);
+/* {{{ proto DOMNodeList dom_document_get_elements_by_tag_name(string tagname) 
U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-A6C9094
 Since: 
 */
@@ -1042,7 +1042,7 @@
 /* }}} end dom_document_get_elements_by_tag_name */
 
 
-/* {{{ proto DOMNode dom_document_import_node(DOMNode importedNode, boolean 
deep);
+/* {{{ proto DOMNode dom_document_import_node(DOMNode importedNode, boolean 
deep) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Core-Document-importNode
 Since: DOM Level 2
 */
@@ -1085,7 +1085,7 @@
 /* }}} end dom_document_import_node */
 
 
-/* {{{ proto DOMElement dom_document_create_element_ns(string namespaceURI, 
string qualifiedName [,string value]);
+/* {{{ proto DOMElement dom_document_create_element_ns(string namespaceURI, 
string qualifiedName [,string value]) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-DocCrElNS
 Since: DOM Level 2
 */
@@ -1149,7 +1149,7 @@
 /* }}} end dom_document_create_element_ns */
 
 
-/* {{{ proto DOMAttr dom_document_create_attribute_ns(string namespaceURI, 
string qualifiedName);
+/* {{{ proto DOMAttr dom_document_create_attribute_ns(string namespaceURI, 
string qualifiedName) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-DocCrAttrNS
 Since: DOM Level 2
 */
@@ -1215,7 +1215,7 @@
 /* }}} end dom_document_create_attribute_ns */
 
 
-/* {{{ proto DOMNodeList dom_document_get_elements_by_tag_name_ns(string 
namespaceURI, string localName);
+/* {{{ proto DOMNodeList dom_document_get_elements_by_tag_name_ns(string 
namespaceURI, string localName) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getElBTNNS
 Since: DOM Level 2
 */
@@ -1243,7 +1243,7 @@
 /* }}} end dom_document_get_elements_by_tag_name_ns */
 
 
-/* {{{ proto DOMElement dom_document_get_element_by_id(string elementId);
+/* {{{ proto DOMElement dom_document_get_element_by_id(string elementId) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-getElBId
 Since: DOM Level 2
 */
@@ -1274,7 +1274,7 @@
 /* }}} end dom_document_get_element_by_id */
 
 
-/* {{{ proto DOMNode dom_document_adopt_node(DOMNode source);
+/* {{{ proto DOMNode dom_document_adopt_node(DOMNode source) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-adoptNode
 Since: DOM Level 3
 */
@@ -1285,7 +1285,7 @@
 /* }}} end dom_document_adopt_node */
 
 
-/* {{{ proto void dom_document_normalize_document();
+/* {{{ proto void dom_document_normalize_document() U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-normalizeDocument
 Since: DOM Level 3
 */
@@ -1306,7 +1306,7 @@
 /* }}} end dom_document_normalize_document */
 
 
-/* {{{ proto DOMNode dom_document_rename_node(node n, string namespaceURI, 
string qualifiedName);
+/* {{{ proto DOMNode dom_document_rename_node(node n, string namespaceURI, 
string qualifiedName) U
 URL: 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-Document3-renameNode
 Since: DOM Level 3
 */
@@ -1316,7 +1316,7 @@
 }
 /* }}} end dom_document_rename_node */
 
-/* {{{ proto void DOMDocument::__construct([string version], [string 
encoding]); */
+/* {{{ proto void DOMDocument::__construct([string version], [string 
encoding]) U */
 PHP_METHOD(domdocument, __construct)
 {
 
@@ -1598,7 +1598,7 @@
 }
 /* }}} end dom_parser_document */
 
-/* {{{ proto DOMNode dom_document_load(string source [, int options]);
+/* {{{ proto DOMNode dom_document_load(string source [, int options]) U
 URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-load
 Since: DOM Level 3
 */
@@ -1608,7 +1608,7 @@
 }
 /* }}} end dom_document_load */
 
-/* {{{ proto DOMNode dom_document_loadxml(string source [, int options]);
+/* {{{ proto DOMNode dom_document_loadxml(string source [, int options]) U
 URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-loadXML
 Since: DOM Level 3
 */
@@ -1618,7 +1618,7 @@
 }
 /* }}} end dom_document_loadxml */
 
-/* {{{ proto int dom_document_save(string file);
+/* {{{ proto int dom_document_save(string file) U
 Convenience method to save to file
 */
 PHP_FUNCTION(dom_document_save)
@@ -1674,7 +1674,7 @@
 }
 /* }}} end dom_document_save */
 
-/* {{{ proto string dom_document_savexml([node n]);
+/* {{{ proto string dom_document_savexml([node n]) U
 URL: http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS-saveXML
 Since: DOM Level 3
 */
@@ -1778,7 +1778,7 @@
        }
 }
 
-/* {{{ proto int dom_document_xinclude([int options])
+/* {{{ proto int dom_document_xinclude([int options]) U
    Substitutues xincludes in a DomDocument */
 PHP_FUNCTION(dom_document_xinclude)
 {
@@ -1818,7 +1818,7 @@
 }
 
 
-/* {{{ proto boolean dom_document_validate();
+/* {{{ proto boolean dom_document_validate() U
 Since: DOM extended
 */
 PHP_FUNCTION(dom_document_validate)
@@ -1951,14 +1951,14 @@
        }
 }
 
-/* {{{ proto boolean dom_document_schema_validate_file(string filename); */
+/* {{{ proto boolean dom_document_schema_validate_file(string filename) U */
 PHP_FUNCTION(dom_document_schema_validate_file)
 {
        _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, 
DOM_LOAD_FILE);
 }
 /* }}} end dom_document_schema_validate_file */
 
-/* {{{ proto boolean dom_document_schema_validate(string source); */
+/* {{{ proto boolean dom_document_schema_validate(string source) U */
 PHP_FUNCTION(dom_document_schema_validate_xml)
 {
        _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, 
DOM_LOAD_STRING);
@@ -2059,14 +2059,14 @@
        }
 }
 
-/* {{{ proto boolean dom_document_relaxNG_validate_file(string filename); */
+/* {{{ proto boolean dom_document_relaxNG_validate_file(string filename) U */
 PHP_FUNCTION(dom_document_relaxNG_validate_file)
 {
        _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, 
DOM_LOAD_FILE);
 }
 /* }}} end dom_document_relaxNG_validate_file */
 
-/* {{{ proto boolean dom_document_relaxNG_validate_xml(string source); */
+/* {{{ proto boolean dom_document_relaxNG_validate_xml(string source) U */
 PHP_FUNCTION(dom_document_relaxNG_validate_xml)
 {
        _dom_document_relaxNG_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, 
DOM_LOAD_STRING);
@@ -2166,7 +2166,7 @@
        }
 }
 
-/* {{{ proto DOMNode dom_document_load_html_file(string source);
+/* {{{ proto DOMNode dom_document_load_html_file(string source) U
 Since: DOM extended
 */
 PHP_METHOD(domdocument, loadHTMLFile)
@@ -2175,7 +2175,7 @@
 }
 /* }}} end dom_document_load_html_file */
 
-/* {{{ proto DOMNode dom_document_load_html(string source);
+/* {{{ proto DOMNode dom_document_load_html(string source) U
 Since: DOM extended
 */
 PHP_METHOD(domdocument, loadHTML)
@@ -2184,7 +2184,7 @@
 }
 /* }}} end dom_document_load_html */
 
-/* {{{ proto int dom_document_save_html_file(string file);
+/* {{{ proto int dom_document_save_html_file(string file) U
 Convenience method to save to file as html
 */
 PHP_FUNCTION(dom_document_save_html_file)
@@ -2232,7 +2232,7 @@
 }
 /* }}} end dom_document_save_html_file */
 
-/* {{{ proto string dom_document_save_html();
+/* {{{ proto string dom_document_save_html() U
 Convenience method to output as html
 */
 PHP_FUNCTION(dom_document_save_html)
@@ -2271,7 +2271,7 @@
 
 #endif  /* defined(LIBXML_HTML_ENABLED) */
 
-/* {{{ proto boolean DOMDocument::registerNodeClass(string baseclass, string 
extendedclass);
+/* {{{ proto boolean DOMDocument::registerNodeClass(string baseclass, string 
extendedclass)
    Register extended class used to create base node type */
 PHP_METHOD(domdocument, registerNodeClass)
 {

http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/domdocument.phpt?view=markup&rev=1.1
Index: php-src/ext/dom/tests/domdocument.phpt
+++ php-src/ext/dom/tests/domdocument.phpt
--TEST--
CharData: DOMCharacterData and related functionality
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
require_once("dom_test.inc");

$dom = new DOMDocument("1.0", "UTF-8");
$root = $dom->createElement('root');
$dom->appendChild($root);

$dom2 = new DOMDocument("1.0");
$dom2->loadXML(b'<doc2><child1>data</child1></doc2>');
$root2 = $dom2->documentElement;

$imported = $dom->importNode($root2->firstChild, TRUE);

$root->appendChild($imported);

$att = $dom->createAttribute('imported');
$attval = $dom->createTextNode('1');
$att->appendChild($attval);
$imported->setAttributeNode($att);

$comment = $dom->createComment('testing DOMDocument functionality');
$dom->insertBefore($comment, $root);

for ($x=1; $x < 3; $x++) {
        if ($x == 2) {
                $node = $dom->createElementNS('urn::foo', 'foo:child', 'data ');
                $entity = $dom->createEntityReference('amp');
                $node->appendChild($entity);
                $node->appendChild(new DOMText(' stuff'));
        } else {
                $node = $dom->createElementNS('urn::foo', 'foo:child');
                $data = $dom->createCDATASection('cdata');
                $node->appendChild($data);
        }
        $root->appendChild($node);

        $att = $dom->createAttributeNS('urn::foo', 'foo:bar');
        $att->appendChild($dom->createTextNode($x));
        $node->setAttributeNode($att);
        $att = $dom->createAttribute('xml:id');
        $att->appendChild($dom->createTextNode('id'.$x));
        $node->setAttributeNode($att);
}

$nodes = $dom->getElementsByTagName('child1');
$node = $nodes->item(0);
$value = $dom->createProcessingInstruction('php', "echo 'Hello World'; ");
$node->replaceChild($value, $node->firstChild);

$nodes = $dom->getElementsByTagNameNS('urn::foo', 'child');
$node = $nodes->item(1);
$frag = $dom->createDocumentFragment();
$frag->appendChild($node);

var_dump($dom->saveXML($frag));

$file = dirname(__FILE__).'/dom.tmp';
$dom->save($file);

$doc = new DOMDocument();
$doc->load($file);

$node = $doc->getElementById('id1');
$node->parentNode->removeChild($node);

print "\n".$doc->saveXML();

unlink($file);

$file = dirname(__FILE__).'/html.tmp';
$doc->loadHTMLFile(dirname(__FILE__).'/test.html');
$doc->saveHTMLFile($file);
$output = $doc->saveHTML();
$dom->loadHTMLFile($file);
$output2 = $dom->saveHTML();

if ($output === $output2) {
        print "\nOutput is identical\n";
} else {
        print "\nOutput is different\n";
}

unlink($file);
?>
--EXPECT--

string(85) "<foo:child xmlns:foo="urn::foo" foo:bar="2" xml:id="id2">data &amp; 
stuff</foo:child>"

<?xml version="1.0" encoding="UTF-8"?>
<!--testing DOMDocument functionality-->
<root xmlns:foo="urn::foo"><child1 imported="1"><?php echo 'Hello World'; 
?></child1></root>

Output is identical


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to