[Phpxd-commits] CVS: phpXD/include/dom Notation.php,NONE,1.1 Attr.php,1.1,1.2 CDataSection.php,1.1,1
Status: Beta
Brought to you by:
growbal
From: Thomas D. <th...@us...> - 2002-02-06 23:07:54
|
Update of /cvsroot/phpxd/phpXD/include/dom In directory usw-pr-cvs1:/tmp/cvs-serv673/include/dom Modified Files: Attr.php CDataSection.php CharacterData.php DOMException.php DOMImplementation.php Document.php DocumentFragment.php DocumentType.php Element.php Entity.php EntityReference.php NamedNodeMap.php Node.php NodeList.php ProcessingInstruction.php Text.php Added Files: Notation.php Log Message: Added support for entities, notations and default values for attributes. --- NEW FILE: Notation.php --- <?php // phpXD - a XML DOM Implementation // // This Software and all associated files are released unter the // GNU Public License (GPL), see LICENSE for details. // // $Id: Notation.php,v 1.1 2002/02/06 23:07:51 thomi Exp $ /** * Class representing the DOM Notation interface. * * @package phpXD * @author Thomas Dohmke <th...@do...> * @version $Revision: 1.1 $ */ class Notation extends Node { /** * Die public identifier URL (URI) for this notation.<br> * DOM-Level 1 * * @private * @type string */ var $publicId; /** * Die system identifier URL (URI) for this notation.<br> * DOM-Level 1 * * @private * @type string */ var $systemId; /** * Constructor of the class. * * @public */ function Notation() { $this->Node(); $this->nodeType = NOTATION_NODE; } /** * Returns the public identifier URL. * * @public * @return string */ function getPublicId() { return $this->publicId; } /** * Returns the system identifier URL. * * @public * @return string */ function getSystemId() { return $this->systemId; } } ?> Index: Attr.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/Attr.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Attr.php 2002/01/25 22:18:18 1.1 --- Attr.php 2002/02/06 23:07:51 1.2 *************** *** 8,17 **** /** ! * Class representing the DOM Attr interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Attr extends Node { /** --- 8,17 ---- /** ! * Class representing the DOM Attr interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Attr extends Node { /** *************** *** 137,140 **** --- 137,141 ---- $this->nodeValue =& $this->firstChild->nodeValue; $this->value =& $this->nodeValue; + $this->specified = true; } Index: CDataSection.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/CDataSection.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** CDataSection.php 2002/01/25 22:18:18 1.1 --- CDataSection.php 2002/02/06 23:07:51 1.2 *************** *** 8,17 **** /** ! * Class representing the DOM CDataSection interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class CDataSection extends Text { /** --- 8,17 ---- /** ! * Class representing the DOM CDataSection interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class CDataSection extends Text { /** Index: CharacterData.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/CharacterData.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** CharacterData.php 2002/01/25 22:18:18 1.1 --- CharacterData.php 2002/02/06 23:07:51 1.2 *************** *** 8,17 **** /** ! * Class representing the DOM CharacterData interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class CharacterData extends Node { /** --- 8,17 ---- /** ! * Class representing the DOM CharacterData interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class CharacterData extends Node { /** Index: DOMException.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/DOMException.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** DOMException.php 2002/01/25 22:18:18 1.1 --- DOMException.php 2002/02/06 23:07:51 1.2 *************** *** 8,144 **** /** ! * Because PHP4 doesn't support exceptions, only the ExceptionCodes are ! * defined. The Functions which normally would like to raise a exception, ! * returns one of this ExceptionCodes. ! * Currently not all ExceptionsCodes are used, only NOT_SUPPORTED_ERR is ! * really often returned. ;=) ! */ /** ! * If index or size is negative, or greater than the allowed value.<br> ! * DOM-Level 1 ! * ! * @const INDEX_SIZE_ERR ! */ define("INDEX_SIZE_ERR", 1); /** ! * If the specified range of text does not fit into a DOMString.<br> ! * DOM-Level 1 ! * ! * @const DOMSTRING_SIZE_ERR ! */ define("DOMSTRING_SIZE_ERR", 2); /** ! * If any node is inserted somewhere it doesn't belong.<br> ! * DOM-Level 1 ! * ! * @const HIERARCHY_REQUEST_ERR ! */ define("HIERARCHY_REQUEST_ERR", 3); /** ! * If a node is used in a different document than the one ! * that created it (that doesn't support it).<br> ! * DOM-Level 1 ! * ! * @const WRONG_DOCUMENT_ERR ! */ define("WRONG_DOCUMENT_ERR", 4); /** ! * If an invalid or illegal character is specified, such as in a name. <br> ! * DOM-Level 1 ! * ! * @const INVALID_CHARACTER_ERR ! */ define("INVALID_CHARACTER_ERR", 5); /** ! * If data is specified for a node which does not support data.<br> ! * DOM-Level 1 ! * ! * @const NO_DATA_ALLOWED_ERR ! */ define("NO_DATA_ALLOWED_ERR", 6); /** ! * If an attempt is made to modify an object where modifications ! * are not allowed.<br> ! * DOM-Level 1 ! * ! * @const NO_MODIFICATION_ALLOWED_ERR ! */ define("NO_MODIFICATION_ALLOWED_ERR", 7); /** ! * If an attempt is made to reference a node in a context where ! * it does not exist.<br> ! * DOM-Level 1 ! * ! * @const NOT_FOUND_ERR ! */ define("NOT_FOUND_ERR", 8); /** ! * If the implementation does not support the requested type of object ! * or operation.<br> ! * DOM-Level 1 ! * ! * @const NOT_SUPPORTED_ERR ! */ define("NOT_SUPPORTED_ERR", 9); /** ! * If an attempt is made to add an attribute that is already in ! * use elsewhere.<br> ! * DOM-Level 1 ! * ! * @const INUSE_ATTRIBUTE_ERR ! */ define("INUSE_ATTRIBUTE_ERR", 10); /** ! * If an attempt is made to use an object that is not, or is no ! * longer, usable.<br> ! * DOM-Level 2 ! * ! * @const INVALID_STATE_ERR ! */ define("INVALID_STATE_ERR", 11); /** ! * If an invalid or illegal string is specified.<br> ! * DOM-Level 2 ! * ! * @const SYNTAX_ERR ! */ define("SYNTAX_ERR", 12); /** ! * If an attempt is made to modify the type of the underlying object.<br> ! * DOM-Level 2 ! * ! * @const INVALID_MODIFICATION_ERR ! */ define("INVALID_MODIFICATION_ERR", 13); /** ! * If an attempt is made to create or change an object in a way which ! * is incorrect with regard to namespaces.<br> ! * DOM-Level 2 ! * ! * @const NAMESPACE_ERR ! */ define("NAMESPACE_ERR", 14); /** ! * If a parameter or an operation is not supported by the underlying object.<br> ! * DOM-Level 2 ! * ! * @const INVALID_ACCESS_ERR ! */ define("INVALID_ACCESS_ERR", 15); - ?> --- 8,144 ---- /** ! * Because PHP4 doesn't support exceptions, only the ExceptionCodes are ! * defined. The Functions which normally would like to raise a exception, ! * returns one of this ExceptionCodes. ! * Currently not all ExceptionsCodes are used, only NOT_SUPPORTED_ERR is ! * really often returned. ;=) ! */ /** ! * If index or size is negative, or greater than the allowed value.<br> ! * DOM-Level 1 ! * ! * @const INDEX_SIZE_ERR ! */ define("INDEX_SIZE_ERR", 1); /** ! * If the specified range of text does not fit into a DOMString.<br> ! * DOM-Level 1 ! * ! * @const DOMSTRING_SIZE_ERR ! */ define("DOMSTRING_SIZE_ERR", 2); /** ! * If any node is inserted somewhere it doesn't belong.<br> ! * DOM-Level 1 ! * ! * @const HIERARCHY_REQUEST_ERR ! */ define("HIERARCHY_REQUEST_ERR", 3); /** ! * If a node is used in a different document than the one ! * that created it (that doesn't support it).<br> ! * DOM-Level 1 ! * ! * @const WRONG_DOCUMENT_ERR ! */ define("WRONG_DOCUMENT_ERR", 4); /** ! * If an invalid or illegal character is specified, such as in a name. <br> ! * DOM-Level 1 ! * ! * @const INVALID_CHARACTER_ERR ! */ define("INVALID_CHARACTER_ERR", 5); /** ! * If data is specified for a node which does not support data.<br> ! * DOM-Level 1 ! * ! * @const NO_DATA_ALLOWED_ERR ! */ define("NO_DATA_ALLOWED_ERR", 6); /** ! * If an attempt is made to modify an object where modifications ! * are not allowed.<br> ! * DOM-Level 1 ! * ! * @const NO_MODIFICATION_ALLOWED_ERR ! */ define("NO_MODIFICATION_ALLOWED_ERR", 7); /** ! * If an attempt is made to reference a node in a context where ! * it does not exist.<br> ! * DOM-Level 1 ! * ! * @const NOT_FOUND_ERR ! */ define("NOT_FOUND_ERR", 8); /** ! * If the implementation does not support the requested type of object ! * or operation.<br> ! * DOM-Level 1 ! * ! * @const NOT_SUPPORTED_ERR ! */ define("NOT_SUPPORTED_ERR", 9); /** ! * If an attempt is made to add an attribute that is already in ! * use elsewhere.<br> ! * DOM-Level 1 ! * ! * @const INUSE_ATTRIBUTE_ERR ! */ define("INUSE_ATTRIBUTE_ERR", 10); /** ! * If an attempt is made to use an object that is not, or is no ! * longer, usable.<br> ! * DOM-Level 2 ! * ! * @const INVALID_STATE_ERR ! */ define("INVALID_STATE_ERR", 11); /** ! * If an invalid or illegal string is specified.<br> ! * DOM-Level 2 ! * ! * @const SYNTAX_ERR ! */ define("SYNTAX_ERR", 12); /** ! * If an attempt is made to modify the type of the underlying object.<br> ! * DOM-Level 2 ! * ! * @const INVALID_MODIFICATION_ERR ! */ define("INVALID_MODIFICATION_ERR", 13); /** ! * If an attempt is made to create or change an object in a way which ! * is incorrect with regard to namespaces.<br> ! * DOM-Level 2 ! * ! * @const NAMESPACE_ERR ! */ define("NAMESPACE_ERR", 14); /** ! * If a parameter or an operation is not supported by the underlying ! * object.<br> ! * DOM-Level 2 ! * ! * @const INVALID_ACCESS_ERR ! */ define("INVALID_ACCESS_ERR", 15); ?> Index: DOMImplementation.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/DOMImplementation.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** DOMImplementation.php 2002/01/29 17:47:31 1.3 --- DOMImplementation.php 2002/02/06 23:07:51 1.4 *************** *** 8,17 **** /** ! * Class representing the DOM DOMImplementation interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class DOMImplementation { /** --- 8,17 ---- /** ! * Class representing the DOM DOMImplementation interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class DOMImplementation { /** Index: Document.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/Document.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Document.php 2002/01/29 20:57:01 1.2 --- Document.php 2002/02/06 23:07:51 1.3 *************** *** 8,17 **** /** ! * Class representing the DOM Document interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Document extends Node { /** --- 8,17 ---- /** ! * Class representing the DOM Document interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Document extends Node { /** *************** *** 50,57 **** */ function Document() { ! Node::Node(); $this->nodeType = DOCUMENT_NODE; $this->nodeName = "#document"; $this->implementation = new DOMImplementation(); } --- 50,58 ---- */ function Document() { ! $this->Node(); $this->nodeType = DOCUMENT_NODE; $this->nodeName = "#document"; $this->implementation = new DOMImplementation(); + $this->ownerDocument =& $this; } *************** *** 117,121 **** $new = new CDataSection(); $new->nodeValue = $data; ! $new->ownerDocument = &$this; return $new; } --- 118,122 ---- $new = new CDataSection(); $new->nodeValue = $data; ! $new->ownerDocument =& $this; return $new; } *************** *** 132,136 **** $new = new Comment(); $new->nodeValue = $data; ! $new->ownerDocument = &$this; return $new; } --- 133,137 ---- $new = new Comment(); $new->nodeValue = $data; ! $new->ownerDocument =& $this; return $new; } *************** *** 159,163 **** $new = new Element(); $new->nodeName = $tagName; ! $new->ownerDocument = &$this; return $new; } --- 160,164 ---- $new = new Element(); $new->nodeName = $tagName; ! $new->ownerDocument =& $this; return $new; } *************** *** 172,176 **** */ function &createEntityReference($name) { ! return NOT_SUPPORTED_ERR; } --- 173,180 ---- */ function &createEntityReference($name) { ! $new = new EntityReference(); ! $new->nodeName = $name; ! $new->ownerDocument =& $this; ! return $new; } *************** *** 188,192 **** $new->nodeValue = $data; $new->nodeName = $target; ! $new->ownerDocument = &$this; return $new; } --- 192,196 ---- $new->nodeValue = $data; $new->nodeName = $target; ! $new->ownerDocument =& $this; return $new; } *************** *** 203,207 **** $new = new Text(); $new->nodeValue = $data; ! $new->ownerDocument = &$this; return $new; } --- 207,211 ---- $new = new Text(); $new->nodeValue = $data; ! $new->ownerDocument =& $this; return $new; } *************** *** 339,343 **** function &importNode(&$importedNode, $deep) { if ($importedNode->nodeType == ATTRIBUTE_NODE) { ! $newNode =& $importedNode->cloneNode(true); $newNode->ownerElement = NULL; $newNode->specified = true; --- 343,347 ---- function &importNode(&$importedNode, $deep) { if ($importedNode->nodeType == ATTRIBUTE_NODE) { ! $newNode =& $importedNode->cloneNode(true, $this); $newNode->ownerElement = NULL; $newNode->specified = true; *************** *** 345,348 **** --- 349,353 ---- else { if (($importedNode->nodeType == ELEMENT_NODE) || + ($importedNode->nodeType == ENTITY_NODE) || ($importedNode->nodeType == DOCUMENT_FRAGMENT_NODE) || ($importedNode->nodeType == PROCESSING_INSTRUCTION_NODE) || *************** *** 350,354 **** ($importedNode->nodeType == CDATA_SECTION_NODE) || ($importedNode->nodeType == COMMENT_NODE)) { ! $newNode =& $importedNode->cloneNode($deep); } else { --- 355,359 ---- ($importedNode->nodeType == CDATA_SECTION_NODE) || ($importedNode->nodeType == COMMENT_NODE)) { ! $newNode =& $importedNode->cloneNode($deep, $this); } else { Index: DocumentFragment.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/DocumentFragment.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** DocumentFragment.php 2002/01/25 22:18:18 1.1 --- DocumentFragment.php 2002/02/06 23:07:51 1.2 *************** *** 8,17 **** /** ! * Class representing the DOM DocumentFragment interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class DocumentFragment extends Node { /** --- 8,17 ---- /** ! * Class representing the DOM DocumentFragment interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class DocumentFragment extends Node { /** Index: DocumentType.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/DocumentType.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** DocumentType.php 2002/01/25 22:18:18 1.1 --- DocumentType.php 2002/02/06 23:07:51 1.2 *************** *** 8,24 **** /** ! * Class representing the DOM DocumentType interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class DocumentType extends Node { /** * A list of all generall entities declared in the DTD.<br> ! * DOM-Level 1-- NYI * * @private ! * @type string */ var $entities; --- 8,33 ---- /** ! * Class representing the DOM DocumentType interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class DocumentType extends Node { /** + * A list off all defined elements and attributes. This is not DOM + * standard! + * + * @private + * @type NamedNodeMap + */ + var $elements; + + /** * A list of all generall entities declared in the DTD.<br> ! * DOM-Level 1 * * @private ! * @type NamedNodeMap */ var $entities; *************** *** 35,42 **** /** * Contains a list of XML notation declarations.<br> ! * DOM-Level 1 -- NYI * * @private ! * @type string */ var $notations; --- 44,51 ---- /** * Contains a list of XML notation declarations.<br> ! * DOM-Level 1 * * @private ! * @type NamedNodeMap */ var $notations; *************** *** 79,84 **** $this->name =& $this->nodeName; ! //$notation = new NamedNodeMap(); ! //$entities = new NamedNodeMap(); } --- 88,94 ---- $this->name =& $this->nodeName; ! $this->notations = new NamedNodeMap(); ! $this->elements = new NamedNodeMap(); ! $this->entities = new NamedNodeMap(); } *************** *** 86,96 **** * Returns a NamedNodeMap containing all general entities declared in the * DTD.<br> ! * DOM-Level 1 -- NYI * * @public * @returns NamedNodeMap */ ! function getEntities() { ! return NOT_SUPPORTED_ERR; } --- 96,106 ---- * Returns a NamedNodeMap containing all general entities declared in the * DTD.<br> ! * DOM-Level 1 * * @public * @returns NamedNodeMap */ ! function &getEntities() { ! return $this->entities; } *************** *** 120,130 **** * Returns a NamedNodeMap containing all notations declared in the * DTD.<br> ! * DOM-Level 1 -- NYI * * @public * @returns NamedNodeMap */ ! function getNotations() { ! return NOT_SUPPORTED_ERR; } --- 130,140 ---- * Returns a NamedNodeMap containing all notations declared in the * DTD.<br> ! * DOM-Level 1 * * @public * @returns NamedNodeMap */ ! function &getNotations() { ! return $this->notation; } Index: Element.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/Element.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Element.php 2002/01/25 22:18:18 1.1 --- Element.php 2002/02/06 23:07:51 1.2 *************** *** 8,17 **** /** ! * Class representing the DOM Element interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Element extends Node { /** --- 8,17 ---- /** ! * Class representing the DOM Element interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Element extends Node { /** *************** *** 56,60 **** function getAttribute($name) { $attr =& $this->getAttributeNode($name); ! return $attr->getValue(); } --- 56,65 ---- function getAttribute($name) { $attr =& $this->getAttributeNode($name); ! if ($attr != NOT_FOUND_ERROR) { ! return $attr->getValue(); ! } ! else { ! return ""; ! } } *************** *** 98,102 **** function removeAttribute($name) { if (isset($this->attributes)) { ! $this->attributes->removeNamedItem($name); } } --- 103,108 ---- function removeAttribute($name) { if (isset($this->attributes)) { ! $attr =& $this->attributes->getNamedItem($name); ! $this->removeAttributeNode($attr); } } *************** *** 111,117 **** */ function &removeAttributeNode(&$oldAttr) { if (isset($this->attributes)) { ! return $this->attributes->removeNamedItem($oldAttr->nodeName); } } --- 117,158 ---- */ function &removeAttributeNode(&$oldAttr) { + $name = $oldAttr->nodeName; + if (isset($oldAttr->namespaceURI)) { + $namespaceURI = $oldAttr->namespaceURI; + } + else { + $namespaceURI = ""; + } if (isset($this->attributes)) { ! if ($namespaceURI == "") { ! $oldAttr =& $this->attributes->removeNamedItem($oldAttr->nodeName); ! } ! else { ! $localName = substr($name, strpos($name, ":") + 1); ! $oldAttr =& $this->attributes->removeNamedItemNS($namespaceURI, ! $localName); ! } ! } ! if (isset($this->ownerDocument->doctype)) { ! $dtdElement =& ! $this->ownerDocument->doctype->elements-> ! getNamedItem($this->nodeName); ! $dtdAttribute =& $dtdElement->attributes->getNamedItem($name); ! if (($dtdAttribute->default == "#FIXED") || ! ($dtdAttribute->defaultValue != "")) { ! if (empty($namespaceURI)) { ! $this->setAttribute($name, $dtdAttribute->defaultValue); ! $attribute =& $this->getAttributeNode($name); ! $attribute->specified = false; ! } ! else { ! $this->setAttributeNS($namespaceURI, $name, ! $dtdAttribute->defaultValue); ! $attribute =& $this->getAttributeNodeNS($namespaceURI, $localName); ! $attribute->specified = false; ! } ! } } + return $oldAttr; } *************** *** 132,135 **** --- 173,177 ---- $new->ownerElement = &$this; $new->ownerDocument = &$this->ownerDocument; + $new->specified = true; if (empty($this->attributes)) { *************** *** 149,152 **** --- 191,196 ---- */ function &setAttributeNode(&$newAttr) { + $newAttr->specified = true; + if (empty($this->attributes)) { $this->attributes = new NamedNodeMap(); *************** *** 198,202 **** function &getElementsByTagNameNS($namespaceURI, $localName) { $result = new NodeList(); ! $this->getElementsByTagNameNSList($namespaceURI, $localName, $this->firstChild, $result); return $result; } --- 242,247 ---- function &getElementsByTagNameNS($namespaceURI, $localName) { $result = new NodeList(); ! $this->getElementsByTagNameNSList($namespaceURI, $localName, ! $this->firstChild, $result); return $result; } *************** *** 256,262 **** */ function removeAttributeNS($namespaceURI, $localName) { ! if (isset($this->attributes)) { ! $this->attributes->removeNamedItemNS($namespaceURI, $localName); ! } } --- 301,306 ---- */ function removeAttributeNS($namespaceURI, $localName) { ! $attr =& $this->getNamedItemNS($namespaceURI, $localName); ! return $this->removeAttributeNode($attr); } *************** *** 272,276 **** function setAttributeNS($namespaceURI, $qualifiedName, $value) { $prefix = substr($qualifiedName, 0, strpos($qualifiedName, ":")); ! $localName = substr($qualifiedName, strpos($this->nodeName, ":")+1); if (empty($prefix) || empty($localName)) { --- 316,320 ---- function setAttributeNS($namespaceURI, $qualifiedName, $value) { $prefix = substr($qualifiedName, 0, strpos($qualifiedName, ":")); ! $localName = substr($qualifiedName, strpos($qualifiedName, ":") + 1); if (empty($prefix) || empty($localName)) { *************** *** 287,300 **** } ! if (($this->namespaceURI != "http://www.w3.org/2000/xmlns/") && ($prefix == "xmlns")) { return NAMESPACE_ERR; } ! if ($this->qualifiedName == "xmlns") { return NAMESPACE_ERR; } $new = new Attr(); $new->nodeName = $qualifiedName; $new->prefix = $prefix; --- 331,345 ---- } ! if (($namespaceURI != "http://www.w3.org/2000/xmlns/") && ($prefix == "xmlns")) { return NAMESPACE_ERR; } ! if ($qualifiedName == "xmlns") { return NAMESPACE_ERR; } $new = new Attr(); + $new->namespaceURI = $namespaceURI; $new->nodeName = $qualifiedName; $new->prefix = $prefix; *************** *** 303,306 **** --- 348,352 ---- $new->ownerElement = &$this; $new->ownerDocument = &$this->ownerDocument; + $new->specified = true; if (empty($this->attributes)) { *************** *** 320,323 **** --- 366,371 ---- */ function setAttributeNodeNS(&$newAttr) { + $newAttr->specified = true; + if (empty($this->attributes)) { $this->attributes = new NamedNodeMap(); Index: Entity.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/Entity.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Entity.php 2002/01/25 22:18:18 1.1 --- Entity.php 2002/02/06 23:07:51 1.2 *************** *** 8,19 **** /** ! * Class representing the DOM Entity interface. Not supported yet. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Entity extends Node { ! // Sorry, not supported yet! } ?> --- 8,85 ---- /** ! * Class representing the DOM Entity interface. Not supported yet. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Entity extends Node { ! /** ! * If the entity is unparsed, notationName is the entity's notation ! * name. For parsed entities , this attribute is null.<br> ! * DOM-Level 1 ! * ! * @private ! * @type string ! */ ! var $notationName = null; ! ! /** ! * Die public identifier URL (URI) for this entity.<br> ! * DOM-Level 1 ! * ! * @private ! * @type string ! */ ! var $publicId; ! ! /** ! * Die system identifier URL (URI) for this entity.<br> ! * DOM-Level 1 ! * ! * @private ! * @type string ! */ ! var $systemId; ! ! /** ! * Constructor of the class. ! * ! * @public ! */ ! function Entity() { ! $this->Node(); ! $this->nodeType = ENTITY_NODE; ! } ! ! /** ! * Returns the notation name of this entity if unparsed. ! * ! * @public ! * @return string ! */ ! function getNotationName() { ! return $this->notationName; ! } ! ! /** ! * Returns the public identifier URL. ! * ! * @public ! * @return string ! */ ! function getPublicId() { ! return $this->publicId; ! } ! ! /** ! * Returns the system identifier URL. ! * ! * @public ! * @return string ! */ ! function getSystemId() { ! return $this->systemId; ! } } ?> Index: EntityReference.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/EntityReference.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** EntityReference.php 2002/01/25 22:18:18 1.1 --- EntityReference.php 2002/02/06 23:07:51 1.2 *************** *** 8,19 **** /** ! * Class representing the DOM EntityReference interface. Not supported yet. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class EntityReference extends Node { ! // Sorry, not supported yet. } ?> --- 8,27 ---- /** ! * Class representing the DOM EntityReference interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class EntityReference extends Node { ! /** ! * Constructor of the class. ! * ! * @public ! */ ! function EntityReference() { ! $this->Node(); ! $this->nodeType = ENTITY_REFERENCE_NODE; ! } } ?> Index: NamedNodeMap.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/NamedNodeMap.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** NamedNodeMap.php 2002/01/25 22:18:18 1.1 --- NamedNodeMap.php 2002/02/06 23:07:51 1.2 *************** *** 8,17 **** /** ! * Class representing the DOM NamedNodeMap interface ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class NamedNodeMap { /** --- 8,17 ---- /** ! * Class representing the DOM NamedNodeMap interface ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class NamedNodeMap { /** *************** *** 66,70 **** $count = 0; reset($this->nodes); ! while (list($key, $value) = each($this->nodes)) { if ($count == $index) { return $this->nodes[$key]; --- 66,70 ---- $count = 0; reset($this->nodes); ! foreach($this->nodes as $key => $value) { if ($count == $index) { return $this->nodes[$key]; *************** *** 112,116 **** } $this->nodes[$arg->nodeName] =& $arg; - return $save; } --- 112,115 ---- Index: Node.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/Node.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Node.php 2002/01/26 13:20:01 1.2 --- Node.php 2002/02/06 23:07:51 1.3 *************** *** 13,80 **** /** ! * @const ATTRIBUTE_NODE ! */ define("ATTRIBUTE_NODE", 2); /** ! * @const TEXT_NODE ! */ define("TEXT_NODE", 3); /** ! * @const CDATA_SECTION_NODE ! */ define("CDATA_SECTION_NODE", 4); /** ! * @const ENTITY_REFERENCE_NODE ! */ define("ENTITY_REFERENCE_NODE", 5); /** ! * @const ENTITY_NODE ! */ define("ENTITY_NODE", 6); /** ! * @const PROCESSING_INSTRUCTION_NODE ! */ define("PROCESSING_INSTRUCTION_NODE", 7); /** ! * @const COMMENT_NODE ! */ define("COMMENT_NODE", 8); /** ! * @const DOCUMENT_NODE ! */ define("DOCUMENT_NODE", 9); /** ! * @const DOCUMENT_TYPE_NODE ! */ define("DOCUMENT_TYPE_NODE", 10); /** ! * @const DOCUMENT_FRAGMENT_NODE ! */ define("DOCUMENT_FRAGMENT_NODE", 11); /** ! * @const NOTATION_NODE ! */ define("NOTATION_NODE", 12); /** ! * Class representing the DOM Node interface ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Node { /** ! * MD5-Hash to compare two nodes. * * This ID is necessary to compare two nodes, because the operator == --- 13,80 ---- /** ! * @const ATTRIBUTE_NODE ! */ define("ATTRIBUTE_NODE", 2); /** ! * @const TEXT_NODE ! */ define("TEXT_NODE", 3); /** ! * @const CDATA_SECTION_NODE ! */ define("CDATA_SECTION_NODE", 4); /** ! * @const ENTITY_REFERENCE_NODE ! */ define("ENTITY_REFERENCE_NODE", 5); /** ! * @const ENTITY_NODE ! */ define("ENTITY_NODE", 6); /** ! * @const PROCESSING_INSTRUCTION_NODE ! */ define("PROCESSING_INSTRUCTION_NODE", 7); /** ! * @const COMMENT_NODE ! */ define("COMMENT_NODE", 8); /** ! * @const DOCUMENT_NODE ! */ define("DOCUMENT_NODE", 9); /** ! * @const DOCUMENT_TYPE_NODE ! */ define("DOCUMENT_TYPE_NODE", 10); /** ! * @const DOCUMENT_FRAGMENT_NODE ! */ define("DOCUMENT_FRAGMENT_NODE", 11); /** ! * @const NOTATION_NODE ! */ define("NOTATION_NODE", 12); /** ! * Class representing the DOM Node interface ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Node { /** ! * Identifier to compare two nodes. * * This ID is necessary to compare two nodes, because the operator == *************** *** 215,219 **** */ var $prefix; ! /** * Constructor of the class. --- 215,227 ---- */ var $prefix; ! ! /** ! * Mark this node as a readonly node. ! * ! * @private ! * @type boolean ! */ ! var $readonly = false; ! /** * Constructor of the class. *************** *** 404,408 **** $newChild->parentNode = &$this; - $newChild->ownerDocument = &$this->ownerDocument; unset($newChild->nextSibling); unset($newChild->previousSibling); --- 412,415 ---- *************** *** 429,437 **** --- 436,460 ---- * @public * @param $deep <code>boolean</code> + * @param $ownerDocument Set the ownerDocument of all cloned nodes. * @returns Node */ function &cloneNode($deep) { + return $this->cloneNode($deep, null); + } + + /** + * Internal function for cloning a node. + * + * @private + * @param $deep <code>boolean</code> + * @param $ownerDocument Set the ownerDocument of all cloned nodes. + * @returns Node + */ + function &cloneNode($deep, $ownerDocument = null) { $clone = $this; $clone->Node(); + if ($ownerDocument != null) { + $clone->ownerDocument = $ownerDocument; + } unset($clone->attributes); unset($clone->childNodes); *************** *** 448,452 **** for ($i = 0; $i < $this->attributes->getLength(); $i++) { $attr =& $this->attributes->item($i); ! $newAttr[$i] =& $attr->cloneNode(true); $newAttr[$i]->specified = true; if (!isset($oldAttr)) { --- 471,475 ---- for ($i = 0; $i < $this->attributes->getLength(); $i++) { $attr =& $this->attributes->item($i); ! $newAttr[$i] =& $attr->cloneNode(true, $ownerDocument); $newAttr[$i]->specified = true; if (!isset($oldAttr)) { *************** *** 469,473 **** for ($i = 0; $i < $this->childNodes->getLength(); $i++) { $child =& $this->childNodes->item($i); ! $newChild[$i] =& $child->cloneNode($deep); if (!isset($oldChild)) { $clone->firstChild = &$newChild[$i]; --- 492,496 ---- for ($i = 0; $i < $this->childNodes->getLength(); $i++) { $child =& $this->childNodes->item($i); ! $newChild[$i] =& $child->cloneNode($deep, $ownerDocument); if (!isset($oldChild)) { $clone->firstChild = &$newChild[$i]; *************** *** 652,656 **** $newChild->parentNode = &$this; - $newChild->ownerDocument = &$this->ownerDocument; if (isset($this->childNodes)) { --- 675,678 ---- *************** *** 813,829 **** $prevChild->nextSibling =& $child->nextSibling; $prevChild->appendData($child->getData()); ! unset($child); ! $child =& $prevChild; ! } ! } ! ! if ($child->nodeType == TEXT_NODE) { ! if ($child->getLength() == 0) { ! $prevChild->nextSibling =& $child->nextSibling; ! unset($child); $child =& $prevChild; } } ! $prevChild =& $child; $child =& $child->nextSibling; --- 835,851 ---- $prevChild->nextSibling =& $child->nextSibling; $prevChild->appendData($child->getData()); ! $this->removeChild($child); $child =& $prevChild; } } ! ! if ($child->nodeType == TEXT_NODE) { ! if ($child->getLength() == 0) { ! $prevChild->nextSibling =& $child->nextSibling; ! $this->removeChild($child); ! $child =& $prevChild; ! } ! } ! $prevChild =& $child; $child =& $child->nextSibling; *************** *** 844,848 **** return HIERARCHY_REQUEST_ERR; } ! if (($this->nodeType == PROCESSING_INSTRUCTION_NODE) || ($this->nodeType == COMMENT_NODE) || --- 866,874 ---- return HIERARCHY_REQUEST_ERR; } ! ! if ($this->readonly) { ! return NO_MODIFICATION_ALLOWED_ERR; ! } ! if (($this->nodeType == PROCESSING_INSTRUCTION_NODE) || ($this->nodeType == COMMENT_NODE) || Index: NodeList.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/NodeList.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** NodeList.php 2002/01/31 10:11:34 1.3 --- NodeList.php 2002/02/06 23:07:51 1.4 *************** *** 8,17 **** /** ! * Class representing the DOM NodeList interface ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class NodeList { /** --- 8,17 ---- /** ! * Class representing the DOM NodeList interface ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class NodeList { /** Index: ProcessingInstruction.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/ProcessingInstruction.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** ProcessingInstruction.php 2002/01/25 22:18:18 1.1 --- ProcessingInstruction.php 2002/02/06 23:07:51 1.2 *************** *** 8,17 **** /** ! * Class representing the DOM ProcessingInstruction interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class ProcessingInstruction extends Node { /** --- 8,17 ---- /** ! * Class representing the DOM ProcessingInstruction interface. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class ProcessingInstruction extends Node { /** Index: Text.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/dom/Text.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Text.php 2002/01/25 22:18:18 1.1 --- Text.php 2002/02/06 23:07:51 1.2 *************** *** 8,17 **** /** ! * Class representing the DOM Text interface ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Text extends CharacterData { /** --- 8,17 ---- /** ! * Class representing the DOM Text interface ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ class Text extends CharacterData { /** |