[Phpxd-commits] CVS: phpXD/include document.php,1.2,1.3 element.php,1.1.1.1,1.2 domimplementation.ph
Status: Beta
Brought to you by:
growbal
|
From: Thomas D. <th...@us...> - 2001-06-28 22:24:26
|
Update of /cvsroot/phpxd/phpXD/include
In directory usw-pr-cvs1:/tmp/cvs-serv32401/include
Modified Files:
document.php element.php domimplementation.php node.php
namednodemap.php
Log Message:
Attributes/Functions for DOM-Level 2 added.
Some Bugs fixed.
Index: document.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/document.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** document.php 2001/06/21 21:59:29 1.2
--- document.php 2001/06/28 22:24:23 1.3
***************
*** 101,105 ****
* @return Attr
*/
! function createAttribute($name)
{
$new = new Attr();
--- 101,105 ----
* @return Attr
*/
! function &createAttribute($name)
{
$new = new Attr();
***************
*** 119,123 ****
* @return CDataSection
*/
! function createCDataSection($data)
{
$new = new CDataSection();
--- 119,123 ----
* @return CDataSection
*/
! function &createCDataSection($data)
{
$new = new CDataSection();
***************
*** 135,139 ****
* @return Comment
*/
! function createComment($data)
{
$new = new Comment();
--- 135,139 ----
* @return Comment
*/
! function &createComment($data)
{
$new = new Comment();
***************
*** 150,154 ****
* @return DocumentFragment
*/
! function createDocumentFragment()
{
$new = new DocumentFragment();
--- 150,154 ----
* @return DocumentFragment
*/
! function &createDocumentFragment()
{
$new = new DocumentFragment();
***************
*** 164,168 ****
* @return Element
*/
! function createElement($tagName)
{
$new = new Element();
--- 164,168 ----
* @return Element
*/
! function &createElement($tagName)
{
$new = new Element();
***************
*** 180,184 ****
* @return EntityReference
*/
! function createEntityReference($name)
{
return NOT_SUPPORTED_ERR;
--- 180,184 ----
* @return EntityReference
*/
! function &createEntityReference($name)
{
return NOT_SUPPORTED_ERR;
***************
*** 194,198 ****
* @return ProcessingInstruction
*/
! function createProcessingInstruction($target, $data)
{
$new = new ProcessingInstruction();
--- 194,198 ----
* @return ProcessingInstruction
*/
! function &createProcessingInstruction($target, $data)
{
$new = new ProcessingInstruction();
***************
*** 211,215 ****
* @return Text
*/
! function createTextNode($data)
{
$new = new Text();
--- 211,215 ----
* @return Text
*/
! function &createTextNode($data)
{
$new = new Text();
***************
*** 228,275 ****
* @return NodeList
*/
! function getElementsByTagName($tagName)
{
! if ($parent == NULL)
! {
! $result = new NodeList();
! $this->getElementsByTagNameList($tagName, $this->documentElement, $result);
! return $result;
! }
}
/**
* Same as createAttribute, but includes support for XML namespaces.
! * DOM-Level 2 -- NYI
*
* @access public
* @return Attr
*/
! function createAttributeNS($namespaceURI, $qualifiedName)
{
! return NOT_SUPPORTED_ERR;
}
/**
* Same as createElement, but includes support for XML namespaces.
! * DOM-Level 2 -- NYI
*
* @access public
* @return Element
*/
! function createElementNS($namespaceURI, $qualifiedName)
{
! return NOT_SUPPORTED_ERR;
}
/**
! * Returns a NodeList of Element nodes from the current document whose
! * id attribute matches the given id.
* DOM-Level 2 -- NYI
*
* @access public
! * @return NodeList
*/
! function getElementById($elementID)
{
return NOT_SUPPORTED_ERR;
}
--- 228,316 ----
* @return NodeList
*/
! function &getElementsByTagName($tagName)
{
! $result = new NodeList();
! $this->getElementsByTagNameList($tagName, $this->documentElement, $result);
! return $result;
}
/**
* Same as createAttribute, but includes support for XML namespaces.
! * DOM-Level 2
*
* @access public
+ * @param string $namespaceURI
+ * @param string $qualifiedName
* @return Attr
*/
! function &createAttributeNS($namespaceURI, $qualifiedName)
{
! $prefix = substr($qualifiedName, 0, strpos($qualifiedName, ":"));
! $localName = substr($qualifiedName, strpos($this->nodeName, ":")+1);
!
! if (empty($prefix) || empty($localName))
! return NAMESPACE_ERR;
!
! if (empty($namespaceURI))
! return NAMESPACE_ERR;
!
! if ($namespaceURI != "http://www.w3.org/XML/1998/namespace" && $prefix == "xml")
! return NAMESPACE_ERR;
!
! if ($this->namespaceURI != "http://www.w3.org/2000/xmlns/" && $prefix == "xmlns")
! return NAMESPACE_ERR;
!
! if ($this->qualifiedName == "xmlns")
! return NAMESPACE_ERR;
!
! $newAttr =& $this->createAttribute($qualifiedName);
! $newAttr->namespaceURI = $namespaceURI;
! $newAttr->localName = $localName;
! $newAttr->prefix = $prefix;
! return $newAttr;
}
/**
* Same as createElement, but includes support for XML namespaces.
! * DOM-Level 2
*
* @access public
+ * @param string $namespaceURI
+ * @param string $qualifiedName
* @return Element
*/
! function &createElementNS($namespaceURI, $qualifiedName)
{
! $prefix = substr($qualifiedName, 0, strpos($qualifiedName, ":"));
! $localName = substr($qualifiedName, strpos($this->nodeName, ":")+1);
!
! if (empty($prefix) || empty($localName))
! return NAMESPACE_ERR;
!
! if (empty($namespaceURI))
! return NAMESPACE_ERR;
!
! if ($namespaceURI != "http://www.w3.org/XML/1998/namespace" && $prefix == "xml")
! return NAMESPACE_ERR;
!
! $newElem =& $this->createElement($qualifiedName);
! $newElem->namespaceURI = $namespaceURI;
! $newElem->localName = $localName;
! $newElem->prefix = $prefix;
! return $newElem;
}
/**
! * Returns a Element node from the current document whose id attribute
! * matches the given id.
* DOM-Level 2 -- NYI
*
* @access public
! * @param string $elementID
! * @return Element
*/
! function &getElementById($elementID)
{
+ // This could not be implemented, as long as the DTD is not parsed.
return NOT_SUPPORTED_ERR;
}
***************
*** 277,288 ****
/**
* Same as getElementByTagName, but includes support for XML namespaces.
! * DOM-Level 2 -- NYI
*
* @access public
* @return NodeList
*/
! function getElementsByTagNameNS($namespaceURI, $localName)
{
! return NOT_SUPPORTED_ERR;
}
--- 318,333 ----
/**
* Same as getElementByTagName, but includes support for XML namespaces.
! * DOM-Level 2
*
* @access public
+ * @param string $namespaceURI
+ * @param string $localName
* @return NodeList
*/
! function &getElementsByTagNameNS($namespaceURI, $localName)
{
! $result = new NodeList();
! $this->getElementsByTagNameNSList($namespaceURI, $localName, $this->documentElement, $result);
! return $result;
}
***************
*** 290,294 ****
* Creates a copy of a Node object from another document that can be
* inserted within the current documents node hierarchy.
! * DOM-Level 2 -- NYI
*
* @access public
--- 335,339 ----
* Creates a copy of a Node object from another document that can be
* inserted within the current documents node hierarchy.
! * DOM-Level 2
*
* @access public
***************
*** 297,303 ****
* @return Node
*/
! function importNode($importedNode, $deep)
{
! return NOT_SUPPORTED_ERR;
}
--- 342,370 ----
* @return Node
*/
! function &importNode(&$importedNode, $deep)
{
! if ($importedNode->nodeType == ATTRIBUTE_NODE)
! {
! $newNode =& $importedNode->cloneNode(true);
! $newNode->ownerElement = NULL;
! $newNode->specified = true;
! }
! else
! if (($importedNode->nodeType == ELEMENT_NODE) ||
! ($importedNode->nodeType == DOCUMENT_FRAGMENT_NODE) ||
! ($importedNode->nodeType == PROCESSING_INSTRUCTION_NODE) ||
! ($importedNode->nodeType == TEXT_NODE) ||
! ($importedNode->nodeType == CDATA_SECTION_NODE) ||
! ($importedNode->nodeType == COMMENT_NODE))
! {
! $newNode =& $importedNode->cloneNode($deep);
! }
! else
! {
! return NOT_SUPPORTED_ERR;
! }
!
! $newNode->ownerDocument =& $this;
! return $newNode;
}
***************
*** 311,315 ****
* @var NodeList $result
*/
! function getElementsByTagNameList($tagName, $parent, &$result)
{
if ($parent->nodeType == ELEMENT_NODE)
--- 378,382 ----
* @var NodeList $result
*/
! function getElementsByTagNameList($tagName, &$parent, &$result)
{
if ($parent->nodeType == ELEMENT_NODE)
***************
*** 332,335 ****
--- 399,436 ----
}
+ /**
+ * Runs recursively through the DOM-Tree and returns a NodeList with all
+ * Element nodes that have the searched $namespaceURI and $localName.
+ *
+ * @access private
+ * @param string $namespaceURI
+ * @param string $localName
+ * @var Node $parent
+ * @var NodeList $result
+ */
+ function getElementsByTagNameNSList($namespaceURI, $localName, &$parent, &$result)
+ {
+ if ($parent->nodeType == ELEMENT_NODE)
+ {
+ if ((($parent->namespaceURI == $namespaceURI) && ($parent->localName == $localName)) ||
+ (($namespaceURI == "*") && ($parent->localName == $localName)) ||
+ (($parent->namespaceURI == $namespaceURI) && ($localName == "*")) ||
+ (($namespaceURI == "*") && ($localName == "*")))
+ {
+ $result->insertNode($parent);
+ }
+
+ if ($parent->hasChildNodes())
+ {
+ $this->getElementsByTagNameNSList($namespaceURI, $localName, $parent->firstChild, $result);
+ }
+ }
+
+ if (isset($parent->nextSibling))
+ {
+ $this->getElementsByTagNameNSList($namespaceURI, $localName, $parent->nextSibling, $result);
+ }
+ }
+
}
Index: element.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/element.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** element.php 2001/06/21 18:59:46 1.1.1.1
--- element.php 2001/06/28 22:24:23 1.2
***************
*** 73,78 ****
function &getAttributeNode($name)
{
! $attr =& $this->attributes->getNamedItem($name);
! return $attr;
}
--- 73,80 ----
function &getAttributeNode($name)
{
! if (isset($this->attributes))
! {
! return $this->attributes->getNamedItem($name);
! }
}
***************
*** 102,106 ****
function removeAttribute($name)
{
! $this->attributes->removeNamedItem($name);
}
--- 104,111 ----
function removeAttribute($name)
{
! if (isset($this->attributes))
! {
! $this->attributes->removeNamedItem($name);
! }
}
***************
*** 113,119 ****
* @return Attr
*/
! function removeAttributeNode(&$oldAttr)
{
! return $this->attributes->removeNamedItem($oldAttr->nodeName);
}
--- 118,127 ----
* @return Attr
*/
! function &removeAttributeNode(&$oldAttr)
{
! if (isset($this->attributes))
! {
! return $this->attributes->removeNamedItem($oldAttr->nodeName);
! }
}
***************
*** 153,156 ****
--- 161,169 ----
function &setAttributeNode(&$newAttr)
{
+ if (empty($this->attributes))
+ {
+ $this->attributes = new NamedNodeMap();
+ }
+
return $this->attributes->setNamedItem($newAttr);
}
***************
*** 158,251 ****
/**
* Same as getAttribute, but includes support for XML namespaces.
! * DOM-Level 2 -- NYI
*
* @access public
! * @return Attr
*/
function getAttributeNS($namespaceURI, $localName)
{
! return NOT_SUPPORTED_ERR;
}
/**
* Same as getAttributeNode, but includes support for XML namespaces.
! * DOM-Level 2 -- NYI
*
* @access public
* @return Attr
*/
! function getAttributeNodeNS($namespaceURI, $localName)
{
! return NOT_SUPPORTED_ERR;
}
/**
* Same as getElementsByTagName, but includes support for XML namespaces.
! * DOM-Level 2 -- NYI
*
* @access public
* @return NodeList
*/
! function getElementsByTagNameNS($namespaceURI, $localName)
{
! return NOT_SUPPORTED_ERR;
}
/**
*
- * DOM-Level 2 -- NYI
- *
* @access public
* @return boolean
*/
function hasAttribute($name)
{
! return NOT_SUPPORTED_ERR;
}
/**
* Same as hasAttribute, but includes support for XML namespaces.
! * DOM-Level 2 -- NYI
*
* @access public
* @return boolean
*/
function hasAttributeNS($namespaceURI, $localName)
{
! return NOT_SUPPORTED_ERR;
}
/**
* Same as removeAttribute, but includes support for XML namespaces.
! * DOM-Level 2 -- NYI
*
* @access public
*/
function removeAttributeNS($namespaceURI, $localName)
{
! return NOT_SUPPORTED_ERR;
}
/**
* Same as setAttribute, but includes support for XML namespaces.
! * DOM-Level 2 -- NYI
*
* @access public
*/
function setAttributeNS($namespaceURI, $qualifiedName, $value)
{
! return NOT_SUPPORTED_ERR;
}
/**
* Same as setAttributeNode, but includes support for XML namespaces.
! * DOM-Level 2 -- NYI
*
* @access public
* @return Attr
*/
function setAttributeNodeNS(&$newAttr)
{
! return NOT_SUPPORTED_ERR;
}
--- 171,348 ----
/**
* Same as getAttribute, but includes support for XML namespaces.
! * DOM-Level 2
*
* @access public
! * @param string $namespaceURI
! * @param string $localName
! * @return string
*/
function getAttributeNS($namespaceURI, $localName)
{
! if (isset($this->attributes))
! {
! $attr =& $this->attributes->getNamedItemNS($namespaceURI, $localName);
! return $attr->getValue();
! }
}
/**
* Same as getAttributeNode, but includes support for XML namespaces.
! * DOM-Level 2
*
* @access public
+ * @param string $namespaceURI
+ * @param string $localName
* @return Attr
*/
! function &getAttributeNodeNS($namespaceURI, $localName)
{
! if (isset($this->attributes))
! {
! return $this->attributes->getNamedItemNS($namespaceURI, $localName);
! }
}
/**
* Same as getElementsByTagName, but includes support for XML namespaces.
! * DOM-Level 2
*
* @access public
* @return NodeList
*/
! function &getElementsByTagNameNS($namespaceURI, $localName)
{
! $result = new NodeList();
! $this->getElementsByTagNameNSList($namespaceURI, $localName, $this->firstChild, $result);
! return $result;
}
/**
+ * Returns true when an attribute with a given name is specified on this
+ * element or has a default value, false otherwise.
+ * DOM-Level 2
*
* @access public
+ * @param string $name
* @return boolean
*/
function hasAttribute($name)
{
! if (empty($this->attributes))
! {
! return false;
! }
!
! $attr =& $this->attributes->getNamedItem($name);
! if (!empty($attr))
! {
! return true;
! }
!
! return false;
}
/**
* Same as hasAttribute, but includes support for XML namespaces.
! * DOM-Level 2
*
* @access public
+ * @param string $namespaceURI
+ * @param string $localName
* @return boolean
*/
function hasAttributeNS($namespaceURI, $localName)
{
! if (empty($this->attributes))
! {
! return false;
! }
!
! $attr =& $this->attributes->getNamedItemNS($namespaceURI, $localName);
! if (!empty($attr))
! {
! return true;
! }
!
! return false;
}
/**
* Same as removeAttribute, but includes support for XML namespaces.
! * DOM-Level 2
*
* @access public
+ * @param string $namespaceURI
+ * @param string $localName
*/
function removeAttributeNS($namespaceURI, $localName)
{
! if (isset($this->attributes))
! {
! $this->attributes->removeNamedItemNS($namespaceURI, $localName);
! }
}
/**
* Same as setAttribute, but includes support for XML namespaces.
! * DOM-Level 2
*
* @access public
+ * @param string $namespaceURI
+ * @param string $localName
+ * @param string $value
*/
function setAttributeNS($namespaceURI, $qualifiedName, $value)
{
! $prefix = substr($qualifiedName, 0, strpos($qualifiedName, ":"));
! $localName = substr($qualifiedName, strpos($this->nodeName, ":")+1);
!
! if (empty($prefix) || empty($localName))
! return NAMESPACE_ERR;
!
! if (empty($namespaceURI))
! return NAMESPACE_ERR;
!
! if ($namespaceURI != "http://www.w3.org/XML/1998/namespace" && $prefix == "xml")
! return NAMESPACE_ERR;
!
! 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;
! $new->localName = $localName;
! $new->setValue($value);
! $new->ownerElement = &$this;
! $new->ownerDocument = &$this->ownerDocument;
!
! if (empty($this->attributes))
! {
! $this->attributes = new NamedNodeMap();
! }
!
! $this->attributes->setNamedItemNS($new);
}
/**
* Same as setAttributeNode, but includes support for XML namespaces.
! * DOM-Level 2
*
* @access public
+ * @var Attr $newAttr
* @return Attr
*/
function setAttributeNodeNS(&$newAttr)
{
! if (empty($this->attributes))
! {
! $this->attributes = new NamedNodeMap();
! }
!
! return $this->attributes->setNamedItemNS($newAttr);
}
***************
*** 259,263 ****
* @var NodeList $result
*/
! function getElementsByTagNameList($tagName, $parent, &$result)
{
if ($parent->nodeType == ELEMENT_NODE)
--- 356,360 ----
* @var NodeList $result
*/
! function getElementsByTagNameList($tagName, &$parent, &$result)
{
if ($parent->nodeType == ELEMENT_NODE)
***************
*** 279,282 ****
--- 376,414 ----
}
}
+
+ /**
+ * Runs recursively through the DOM-Tree and returns a NodeList with all
+ * Element nodes that have the searched $namespaceURI and $localName.
+ *
+ * @access private
+ * @param string $namespaceURI
+ * @param string $localName
+ * @var Node $parent
+ * @var NodeList $result
+ */
+ function getElementsByTagNameNSList($namespaceURI, $localName, &$parent, &$result)
+ {
+ if ($parent->nodeType == ELEMENT_NODE)
+ {
+ if ((($parent->namespaceURI == $namespaceURI) && ($parent->localName == $localName)) ||
+ (($namespaceURI == "*") && ($parent->localName == $localName)) ||
+ (($parent->namespaceURI == $namespaceURI) && ($localName == "*")) ||
+ (($namespaceURI == "*") && ($localName == "*")))
+ {
+ $result->insertNode($parent);
+ }
+
+ if ($parent->hasChildNodes())
+ {
+ $this->getElementsByTagNameNSList($namespaceURI, $localName, $parent->firstChild, $result);
+ }
+ }
+
+ if (isset($parent->nextSibling))
+ {
+ $this->getElementsByTagNameNSList($namespaceURI, $localName, $parent->nextSibling, $result);
+ }
+ }
+
}
Index: domimplementation.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/domimplementation.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** domimplementation.php 2001/06/21 18:59:45 1.1.1.1
--- domimplementation.php 2001/06/28 22:24:23 1.2
***************
*** 41,45 ****
/**
* Creates a new, empty Document with the given document type.
! * DOM-Level 2 -- NYI
*
* @access public
--- 41,45 ----
/**
* Creates a new, empty Document with the given document type.
! * DOM-Level 2
*
* @access public
***************
*** 49,55 ****
* @return Document
*/
! function createDocument($namespaceURI, $qualifiedName, $doctype)
{
! return NOT_SUPPORTED_ERR;
}
--- 49,85 ----
* @return Document
*/
! function &createDocument($namespaceURI, $qualifiedName, &$doctype)
{
! if (!(strpos($qualifiedName, ":") === false))
! {
! $prefix = substr($qualifiedName, 0, strpos($qualifiedName, ":"));
! $localName = substr($qualifiedName, strpos($this->nodeName, ":")+1);
!
! if (empty($prefix) || empty($localName))
! return NAMESPACE_ERR;
! }
! else
! {
! if (empty($qualifiedName))
! return NAMESPACE_ERR;
! }
!
! if (empty($namespaceURI))
! return NAMESPACE_ERR;
!
! if ($namespaceURI != "http://www.w3.org/XML/1998/namespace" && $prefix == "xml")
! return NAMESPACE_ERR;
!
! if (!empty($doctype->ownerDocument))
! return WRONG_DOCUMENT_ERR;
!
! $doc = new Document();
! $doc->doctype =& $doctype;
! $doc->doctype->ownerDocument =& $this;
! $doc->doctype->namespaceURI = $namespaceURI;
! $doc->namespaceURI = $namespaceURI;
! $doc->prefix = $prefix;
! $doc->localName = $localName;
! return $doc;
}
***************
*** 57,61 ****
* Creates an empty DocumentType node that is not associated with any
* document.
! * DOM-Level 2 -- NYI
*
* @access public
--- 87,91 ----
* Creates an empty DocumentType node that is not associated with any
* document.
! * DOM-Level 2
*
* @access public
***************
*** 67,71 ****
function createDocumentType($qualifiedName, $publicId, $systemId)
{
! return NOT_SUPPORTED_ERR;
}
--- 97,121 ----
function createDocumentType($qualifiedName, $publicId, $systemId)
{
! if (!(strpos($qualifiedName, ":") === false))
! {
! $prefix = substr($qualifiedName, 0, strpos($qualifiedName, ":"));
! $localName = substr($qualifiedName, strpos($this->nodeName, ":")+1);
!
! if (empty($prefix) || empty($localName))
! return NAMESPACE_ERR;
! }
! else
! {
! if (empty($qualifiedName))
! return NAMESPACE_ERR;
! }
!
! $dtd = new DocumentType();
! $dtd->publicId = $publicId;
! $dtd->systemId = $systemId;
! $dtd->nodeName = $qualifiedName;
! $dtd->prefix = $prefix;
! $dtd->localName = $localName;
! return $dtd;
}
Index: node.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/node.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** node.php 2001/06/28 17:18:48 1.2
--- node.php 2001/06/28 22:24:23 1.3
***************
*** 462,490 ****
unset($clone->previousSibling);
! if ($deep)
{
! if (isset($this->attributes))
! {
! $clone->attributes = new NamedNodeMap();
! unset($oldAttr);
! for ($i = 0; $i < $this->attributes->getLength(); $i++)
{
! $attr =& $this->attributes->item($i);
! $newAttr[$i] =& $attr->cloneNode($deep);
! if (!isset($oldAttr))
! {
! $clone->firstAttr = &$newAttr[$i];
! }
! else
! {
! $oldAttr->nextSibling = &$newAttr[$i];
! $newAttr[$i]->previousSibling = &$oldAttr;
! }
! $clone->attributes->setNamedItem($newAttr[$i]);
! $oldAttr = &$newAttr[$i];
}
! $clone->lastAttr = &$oldAttr;
}
if (isset($this->childNodes))
{
--- 462,492 ----
unset($clone->previousSibling);
! if (isset($this->attributes))
{
! $clone->attributes = new NamedNodeMap();
! unset($oldAttr);
! 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))
{
! $clone->firstAttr = &$newAttr[$i];
}
! else
! {
! $oldAttr->nextSibling = &$newAttr[$i];
! $newAttr[$i]->previousSibling = &$oldAttr;
! }
! $clone->attributes->setNamedItem($newAttr[$i]);
! $oldAttr = &$newAttr[$i];
}
+ $clone->lastAttr = &$oldAttr;
+ }
+
+ if ($deep)
+ {
if (isset($this->childNodes))
{
***************
*** 793,797 ****
$this->prefix = $prefix;
! $this->nodeName = $prefix.substr($this->nodeName, 0, strpos($this->nodeName, ":"));
}
--- 795,799 ----
$this->prefix = $prefix;
! $this->nodeName = $prefix.substr($this->nodeName, strpos($this->nodeName, ":"));
}
***************
*** 970,973 ****
--- 972,980 ----
function checkDocument(&$child)
{
+ if (empty($child->ownerDocument))
+ {
+ return 0;
+ }
+
if (($child->ownerDocument->nodeID != $this->ownerDocument->nodeID) &&
(($this->nodeType != DOCUMENT_NODE) && ($this->nodeType != DOCUMENT_TYPE_NODE)))
***************
*** 975,978 ****
--- 982,986 ----
return WRONG_DOCUMENT_ERR;
}
+
return 0;
}
Index: namednodemap.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/namednodemap.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** namednodemap.php 2001/06/21 18:59:48 1.1.1.1
--- namednodemap.php 2001/06/28 22:24:23 1.2
***************
*** 91,95 ****
* a reference to the removed item.
*/
! function removeNamedItem($name)
{
if (isset($this->nodes[$name]))
--- 91,95 ----
* a reference to the removed item.
*/
! function &removeNamedItem($name)
{
if (isset($this->nodes[$name]))
***************
*** 119,123 ****
* node is returned, otherwise null is returned.
*/
! function setNamedItem(&$arg)
{
if (!isset($this->nodes[$arg->nodeName]))
--- 119,123 ----
* node is returned, otherwise null is returned.
*/
! function &setNamedItem(&$arg)
{
if (!isset($this->nodes[$arg->nodeName]))
***************
*** 139,143 ****
/**
* Retrieves a node specified by local name and namespace URI.
! * DOM-Level 2 -- NYI
*
* @access public
--- 139,143 ----
/**
* Retrieves a node specified by local name and namespace URI.
! * DOM-Level 2
*
* @access public
***************
*** 146,157 ****
* @return mixed
*/
! function getNamedItemNS($namespaceURI, $localName)
{
! return NOT_SUPPORTED_ERR;
}
/**
* Removes a node specified by local name and namespace URI.
! * DOM-Level 2 -- NYI
*
* @access public
--- 146,157 ----
* @return mixed
*/
! function &getNamedItemNS($namespaceURI, $localName)
{
! return $this->getNamedItem($namespaceURI.":".$localName);
}
/**
* Removes a node specified by local name and namespace URI.
! * DOM-Level 2
*
* @access public
***************
*** 160,180 ****
* @return mixed
*/
! function removeNamedItemNS($namespaceURI, $localName)
{
! return NOT_SUPPORTED_ERR;
}
/**
* Adds a node using its $namespaceURI and $localName
! * DOM-Level 2 -- NYI
*
* @access public
! * @param string $namespaceURI
! * @param string $localName
! * @return mixed
*/
! function setNamedItemNS($arg)
{
! return NOT_SUPPORTED_ERR;
}
}
--- 160,193 ----
* @return mixed
*/
! function &removeNamedItemNS($namespaceURI, $localName)
{
! return $this->removeNamedItem($namespaceURI.":".$localName);
}
/**
* Adds a node using its $namespaceURI and $localName
! * DOM-Level 2
*
* @access public
! * @param Node $arg
! * @return mixed If the new node replaces an existing node the replaced
! * node is returned, otherwise null is returned.
*/
! function &setNamedItemNS(&$arg)
{
! if (!isset($this->nodes[$arg->namespaceURI.":".$arg->localName]))
! {
! $this->length++;
! $save = null;
! }
! else
! {
! $save =& $this->nodes[$arg->namespaceURI.":".$arg->localName];
! }
! $this->nodes[$arg->namespaceURI.":".$arg->localName] =& $arg;
!
! return $save;
!
! /* todo: Exceptions: INUSE_ATTRIBUTE_ERR, WRONG_DOCUMENT_ERR */
}
}
|