phpxd-commits Mailing List for phpXD (Page 6)
Status: Beta
Brought to you by:
growbal
You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(6) |
Jul
(4) |
Aug
|
Sep
(1) |
Oct
|
Nov
(14) |
Dec
(2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
(49) |
Feb
(43) |
Mar
(15) |
Apr
|
May
|
Jun
(10) |
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
|
From: Thomas D. <th...@us...> - 2001-11-27 20:58:29
|
Update of /cvsroot/phpxd/phpXD/include
In directory usw-pr-cvs1:/tmp/cvs-serv2696/include
Modified Files:
node.php
Log Message:
Speed up with factor 10 cause Node() no longer uses uniqid() which is
quite slow. Instead the a combination of microtime and rand is used.
Index: node.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/node.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** node.php 2001/11/27 20:32:34 1.4
--- node.php 2001/11/27 20:58:25 1.5
***************
*** 222,227 ****
*/
function Node() {
! srand((double)microtime()*1000000);
! $this->nodeID = md5(uniqid(rand()));
}
--- 222,226 ----
*/
function Node() {
! $this->nodeID = microtime()." ".rand();
}
***************
*** 908,937 ****
return 0;
- }
-
- /**
- * Same as appendChild, but no check whether the new child is a valid child
- * type, if it has a parent or if it has siblings;
- * Used to speed up loading a file; Be careful if you use this method.
- *
- * @private
- * @param $newChild <a href="Node.html">Node</a>
- * @returns void
- */
- function &appendChildFast(&$newChild) {
- $newChild->parentNode = &$this;
- $newChild->ownerDocument = &$this->ownerDocument;
-
- if (!isset($this->firstChild)) {
- $this->firstChild = &$newChild;
- $this->lastChild = &$newChild;
- $this->childNodes = new NodeList();
- }
- else {
- $this->lastChild->nextSibling = &$newChild;
- $newChild->previousSibling = &$this->lastChild;
- $this->lastChild = &$newChild;
- }
- $this->childNodes->insertNode($newChild);
}
}
--- 907,910 ----
|
|
From: Thomas D. <th...@us...> - 2001-11-27 20:56:45
|
Update of /cvsroot/phpxd/phpXD
In directory usw-pr-cvs1:/tmp/cvs-serv2524
Modified Files:
phpXD.php
Log Message:
Little changes...
Index: phpXD.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/phpXD.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** phpXD.php 2001/11/27 20:34:29 1.19
--- phpXD.php 2001/11/27 20:56:40 1.20
***************
*** 315,319 ****
}
else {
! $this->currentNode->appendChildFast($newChild);
$this->currentNode =& $newChild;
}
--- 315,319 ----
}
else {
! $this->currentNode->appendChild($newChild);
$this->currentNode =& $newChild;
}
***************
*** 395,399 ****
}
else {
! $this->lastNode =& $this->currentNode->appendChildFast(
$this->document->createCDataSection($text));
}
--- 395,399 ----
}
else {
! $this->lastNode =& $this->currentNode->appendChild(
$this->document->createCDataSection($text));
}
***************
*** 406,410 ****
if (trim($text) != "") {
! $this->lastNode =& $this->currentNode->appendChildFast(
$this->document->createTextNode($text));
}
--- 406,410 ----
if (trim($text) != "") {
! $this->lastNode =& $this->currentNode->appendChild(
$this->document->createTextNode($text));
}
***************
*** 420,428 ****
function handleProcessingInstruction($parser, $target, $data) {
if (!isset($this->document->documentElement)) {
! $this->document->appendChildFast(
$this->document->createProcessingInstruction($target, $data));
}
else {
! $this->lastNode =& $this->currentNode->appendChildFast(
$this->document->createProcessingInstruction(
$target, $data));
--- 420,428 ----
function handleProcessingInstruction($parser, $target, $data) {
if (!isset($this->document->documentElement)) {
! $this->document->appendChild(
$this->document->createProcessingInstruction($target, $data));
}
else {
! $this->lastNode =& $this->currentNode->appendChild(
$this->document->createProcessingInstruction(
$target, $data));
***************
*** 494,502 ****
$data = str_replace("-->", "", $data);
if (!isset($this->document->documentElement)) {
! $this->document->appendChildFast(
$this->document->createComment($data));
}
else {
! $this->lastNode =& $this->currentNode->appendChildFast(
$this->document->createComment($data));
}
--- 494,502 ----
$data = str_replace("-->", "", $data);
if (!isset($this->document->documentElement)) {
! $this->document->appendChild(
$this->document->createComment($data));
}
else {
! $this->lastNode =& $this->currentNode->appendChild(
$this->document->createComment($data));
}
|
|
From: Thomas D. <th...@us...> - 2001-11-27 20:34:34
|
Update of /cvsroot/phpxd/phpXD In directory usw-pr-cvs1:/tmp/cvs-serv28583 Modified Files: phpXD.php Log Message: Changed source documentation for using PHPDoc (see http://www.callowayprints.com/phpdoc). Index: phpXD.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/phpXD.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** phpXD.php 2001/11/26 21:26:58 1.18 --- phpXD.php 2001/11/27 20:34:29 1.19 *************** *** 7,24 **** // $Id$ - /** - * Class for accessing XML data through the W3C DOM. - * - * This class offers methods for accessing the nodes of a XML document using - * the Document Object Model Level 1 (DOM). For parsing the XML files, the PHP - * XML extension (libexpat) is used. Some interface supports DOM Level 2 yet. - * - * @package phpXD - * @author Thomas Dohmke <th...@do...> - * @link http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html - * @link http://www.w3.org/TR/DOM-Level-2-Core - * @version $Revision$ - */ - require("include/node.php"); require("include/attr.php"); --- 7,10 ---- *************** *** 39,44 **** require("include/cdatasection.php"); ! class phpXD ! { /** * The Document node. --- 25,38 ---- require("include/cdatasection.php"); ! /** ! * This class offers methods for accessing the nodes of a XML document using ! * the Document Object Model Level 1 (DOM). For parsing the XML files, the PHP ! * XML extension (libexpat) is used. Some interface supports DOM Level 2 yet. ! * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! */ ! class phpXD { /** * The Document node. *************** *** 105,109 **** * * @public ! * @param $file A filename of a XML file. */ function phpXD($file = "") { --- 99,104 ---- * * @public ! * @param $file <code>string</code> ! * @returns phpXD */ function phpXD($file = "") { *************** *** 120,124 **** * * @public ! * @param $file A filename of a XML file. */ function loadFile($file) { --- 115,120 ---- * * @public ! * @param $file <code>string</code> ! * @returns phpXD */ function loadFile($file) { *************** *** 162,167 **** * * @public ! * @param $dom The documentElement of a DOM. ! * @param $trim <code>true</code> or <code>false</code>. */ function saveFile($file, $trim = false) { --- 158,164 ---- * * @public ! * @param $dom <a href="Document.html">Document</a> ! * @param $trim <code>boolean</code> ! * @returns void */ function saveFile($file, $trim = false) { *************** *** 177,185 **** * * @private ! * @param $dom ! * @param $deep ! * @param $trim ! * @param $text ! * @param $file */ function saveTree(&$dom, $deep, $trim, &$text) { --- 174,182 ---- * * @private ! * @param $dom <a href="Document.html">Document</a> ! * @param $deep <code>boolean</code> ! * @param $trim <code>boolean</code> ! * @param $text <code>string</code> ! * @returns void */ function saveTree(&$dom, $deep, $trim, &$text) { *************** *** 278,281 **** --- 275,279 ---- * * @private + * @returns void */ function handleStartElement($parser, $name, $attributes) { *************** *** 302,305 **** --- 300,308 ---- if (!(strpos($name, ":") === false)) { $newChild =& $this->document->createElementNS($namespace, $name); + + if ($newChild == NAME_SPACE_ERR) { + $this->displayError("XML error: namespace not valid in line %d.", + xml_get_current_line_number($parser)); + } } else { *************** *** 307,315 **** } - if ($newChild == NAME_SPACE_ERR) { - $this->displayError("XML error: namespace not valid in line %d.", - xml_get_current_line_number($parser)); - } - if (!isset($this->document->documentElement)) { $this->document->documentElement =& $newChild; --- 310,313 ---- *************** *** 317,321 **** } else { ! $this->currentNode->appendChild($newChild); $this->currentNode =& $newChild; } --- 315,319 ---- } else { ! $this->currentNode->appendChildFast($newChild); $this->currentNode =& $newChild; } *************** *** 374,377 **** --- 372,376 ---- * * @private + * @returns void */ function handleEndElement($parser, $name) { *************** *** 384,387 **** --- 383,387 ---- * * @private + * @returns void */ function handleCharacterData($parser, $text) { *************** *** 395,410 **** } else { ! $this->lastNode =& $this->currentNode->appendChild( $this->document->createCDataSection($text)); } } else { ! $text = str_replace("\t", "", $text); $text = str_replace("\n", " ", $text); ! $text = str_replace("\r", "", $text); $text = str_replace(" ", " ", $text); ! if (trim($text) == "") { ! $this->lastNode =& $this->currentNode->appendChild( $this->document->createTextNode($text)); } --- 395,410 ---- } else { ! $this->lastNode =& $this->currentNode->appendChildFast( $this->document->createCDataSection($text)); } } else { ! $text = str_replace("\t", " ", $text); $text = str_replace("\n", " ", $text); ! $text = str_replace("\r", " ", $text); $text = str_replace(" ", " ", $text); ! if (trim($text) != "") { ! $this->lastNode =& $this->currentNode->appendChildFast( $this->document->createTextNode($text)); } *************** *** 416,427 **** * * @private */ function handleProcessingInstruction($parser, $target, $data) { if (!isset($this->document->documentElement)) { ! $this->document->appendChild( $this->document->createProcessingInstruction($target, $data)); } else { ! $this->lastNode =& $this->currentNode->appendChild( $this->document->createProcessingInstruction( $target, $data)); --- 416,428 ---- * * @private + * @returns void */ function handleProcessingInstruction($parser, $target, $data) { if (!isset($this->document->documentElement)) { ! $this->document->appendChildFast( $this->document->createProcessingInstruction($target, $data)); } else { ! $this->lastNode =& $this->currentNode->appendChildFast( $this->document->createProcessingInstruction( $target, $data)); *************** *** 434,440 **** --- 435,446 ---- * * @private + * @returns void */ function handleDTD($parser, $data) { $data = trim($data); + if ($data == "") { + return; + } + if (!empty($data)) { $this->parsedDTD .= " ".$data; *************** *** 476,490 **** * * @private */ function handleDefault($parser, $data) { $data = trim($data); if (!(strpos($data, "<!--") === false)) { $data = str_replace("<!--", "", $data); $data = str_replace("-->", "", $data); if (!isset($this->document->documentElement)) { ! $this->document->appendChild($this->document->createComment($data)); } else { ! $this->lastNode =& $this->currentNode->appendChild( $this->document->createComment($data)); } --- 482,502 ---- * * @private + * @returns void */ function handleDefault($parser, $data) { $data = trim($data); + if ($data == "") { + return; + } + if (!(strpos($data, "<!--") === false)) { $data = str_replace("<!--", "", $data); $data = str_replace("-->", "", $data); if (!isset($this->document->documentElement)) { ! $this->document->appendChildFast( ! $this->document->createComment($data)); } else { ! $this->lastNode =& $this->currentNode->appendChildFast( $this->document->createComment($data)); } *************** *** 515,518 **** --- 527,531 ---- * * @private + * @returns void */ function displayError($message) { |
|
From: Thomas D. <th...@us...> - 2001-11-27 20:32:38
|
Update of /cvsroot/phpxd/phpXD/include In directory usw-pr-cvs1:/tmp/cvs-serv27808/include Modified Files: attr.php cdatasection.php characterdata.php comment.php document.php documentfragment.php documenttype.php domexception.php domimplementation.php element.php entity.php entityreference.php namednodemap.php node.php nodelist.php processinginstruction.php text.php Log Message: Changed source documentation for using PHPDoc (see http://www.callowayprints.com/phpdoc). Index: attr.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/attr.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** attr.php 2001/11/26 21:11:37 1.4 --- attr.php 2001/11/27 20:32:34 1.5 *************** *** 14,21 **** * @version $Revision$ */ ! class Attr extends Node ! { /** ! * The name of the attribute. * DOM-Level 1 * --- 14,20 ---- * @version $Revision$ */ ! class Attr extends Node { /** ! * The name of the attribute.<br> * DOM-Level 1 * *************** *** 26,31 **** /** ! * A link to the Element object that owns this attribute. If it is unowned, ! * it equals NULL. * DOM-Level 2 * --- 25,29 ---- /** ! * A link to the Element object that owns this attribute.<br> * DOM-Level 2 * *************** *** 38,42 **** * If this attribute was explicity set in the XML source for the parent * element or it is a default value in the DTD (currently not supported by ! * phpXD) specified is true. * DOM-Level 1 * --- 36,40 ---- * If this attribute was explicity set in the XML source for the parent * element or it is a default value in the DTD (currently not supported by ! * phpXD) specified is true.<br> * DOM-Level 1 * *************** *** 47,51 **** /** ! * The value of the attribute. * DOM-Level 1 * --- 45,49 ---- /** ! * The value of the attribute.<br> * DOM-Level 1 * *************** *** 68,76 **** /** ! * Returns the name of the attribute. * DOM-Level 1 * * @public ! * @return string */ function getName() { --- 66,74 ---- /** ! * Returns the name of the attribute.<br> * DOM-Level 1 * * @public ! * @returns string */ function getName() { *************** *** 79,87 **** /** ! * Returns a reference to the owner of the attribute. * DOM-Level 2 * * @public ! * @return Node */ function &getOwnerElement() { --- 77,85 ---- /** ! * Returns a reference to the owner of the attribute.<br> * DOM-Level 2 * * @public ! * @returns Node */ function &getOwnerElement() { *************** *** 91,99 **** /** * Returns true if the attribute was set explicity in the XML Source or in ! * the DTD (not supported). * DOM-Level 1 * * @public ! * @return boolean */ function getSpecified() { --- 89,97 ---- /** * Returns true if the attribute was set explicity in the XML Source or in ! * the DTD (not supported).<br> * DOM-Level 1 * * @public ! * @returns boolean */ function getSpecified() { *************** *** 102,110 **** /** ! * Return the value of the attribute. * DOM-Level 1 * * @public ! * @return string */ function getValue() { --- 100,108 ---- /** ! * Return the value of the attribute.<br> * DOM-Level 1 * * @public ! * @returns string */ function getValue() { *************** *** 115,123 **** /** ! * Sets the value of the attribute * DOM-Level 1 * * @public ! * @param $value A string. */ function setValue($value) { --- 113,122 ---- /** ! * Sets the value of the attribute<br> * DOM-Level 1 * * @public ! * @param $value <code>string</code> ! * @returns void */ function setValue($value) { *************** *** 142,149 **** /** * Sets the value of the attribute (inherited function from Node interface) ! * DOM-Level 1 * * @public ! * @param $nodeValue A String. */ function setNodeValue($nodeValue) { --- 141,149 ---- /** * Sets the value of the attribute (inherited function from Node interface) ! * <br>DOM-Level 1 * * @public ! * @param $nodeValue <code>string</code> ! * @returns void */ function setNodeValue($nodeValue) { *************** *** 153,161 **** /** * This inherited function from Node interface is not supported by the Attr ! * interface. * DOM-Level 1 * * @public ! * @return NOT_SUPPORTED_ERR */ function &appendChild(&$newChild) { --- 153,161 ---- /** * This inherited function from Node interface is not supported by the Attr ! * interface.<br> * DOM-Level 1 * * @public ! * @returns NOT_SUPPORTED_ERR */ function &appendChild(&$newChild) { *************** *** 165,173 **** /** * This inherited function from Node interface is not supported by the Attr ! * interface. * DOM-Level 1 * * @public ! * @return NOT_SUPPORTED_ERR */ function &insertBefore(&$newChild, &$refChild) { --- 165,173 ---- /** * This inherited function from Node interface is not supported by the Attr ! * interface.<br> * DOM-Level 1 * * @public ! * @returns NOT_SUPPORTED_ERR */ function &insertBefore(&$newChild, &$refChild) { *************** *** 177,185 **** /** * This inherited function from Node interface is not supported by the Attr ! * interface. * DOM-Level 1 * * @public ! * @return NOT_SUPPORTED_ERR */ function &replaceChild($newChild, $oldChild) { --- 177,185 ---- /** * This inherited function from Node interface is not supported by the Attr ! * interface.<br> * DOM-Level 1 * * @public ! * @returns NOT_SUPPORTED_ERR */ function &replaceChild($newChild, $oldChild) { Index: cdatasection.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/cdatasection.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** cdatasection.php 2001/11/26 23:39:27 1.2 --- cdatasection.php 2001/11/27 20:32:34 1.3 *************** *** 14,19 **** * @version $Revision$ */ ! class CDataSection extends Text ! { /** * Constructor of the class. --- 14,18 ---- * @version $Revision$ */ ! class CDataSection extends Text { /** * Constructor of the class. Index: characterdata.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/characterdata.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** characterdata.php 2001/11/26 23:39:27 1.2 --- characterdata.php 2001/11/27 20:32:34 1.3 *************** *** 14,21 **** * @version $Revision$ */ ! class CharacterData extends Node ! { /** ! * The "raw" data of the CharacterData node. * DOM-Level 1 * --- 14,20 ---- * @version $Revision$ */ ! class CharacterData extends Node { /** ! * The "raw" data of the CharacterData node.<br> * DOM-Level 1 * *************** *** 26,30 **** /** ! * The size of the string stored in data. * DOM-Level 1 * --- 25,29 ---- /** ! * The size of the string stored in data.<br> * DOM-Level 1 * *************** *** 45,53 **** /** ! * Returns the data stored in this node. * DOM-Level 1 * * @public ! * @return string */ function getData() { --- 44,52 ---- /** ! * Returns the data stored in this node.<br> * DOM-Level 1 * * @public ! * @returns string */ function getData() { *************** *** 56,65 **** /** ! * Sets the data stored in this node. * DOM-Level 1 * * @public ! * @param $data ! * @return string */ function setData($data) { --- 55,64 ---- /** ! * Sets the data stored in this node.<br> * DOM-Level 1 * * @public ! * @param $data <code>string</code> ! * @returns string */ function setData($data) { *************** *** 68,76 **** /** ! * Returns the length of the data stored in this node. * DOM-Level 1 * * @public ! * @return string */ function getLength() { --- 67,75 ---- /** ! * Returns the length of the data stored in this node.<br> * DOM-Level 1 * * @public ! * @returns string */ function getLength() { *************** *** 80,89 **** /** * Appends contents of the arg parameter to the current contents of the data ! * attribute. * DOM-Level 1 * * @public ! * @param $arg ! * @return string */ function appendData($arg) { --- 79,88 ---- /** * Appends contents of the arg parameter to the current contents of the data ! * attribute.<br> * DOM-Level 1 * * @public ! * @param $arg <code>string</code> ! * @returns string */ function appendData($arg) { *************** *** 92,103 **** /** ! * Truncates the data attribute. It removes count characters, starting at ! * the offset position. * DOM-Level 1 * * @public ! * @param $offset ! * @param $count ! * @return string */ function deleteData($offset, $count) { --- 91,102 ---- /** ! * Truncates the data attribute; It removes count characters, starting at ! * the offset position.<br> * DOM-Level 1 * * @public ! * @param $offset <code>int</code> ! * @param $count <code>int</code> ! * @returns string */ function deleteData($offset, $count) { *************** *** 108,116 **** /** * Takes a string, splits the data attributes current contents at the given ! * offset, then inserts the string arg between the two substrings. * DOM-Level 1 * * @public ! * @return string */ function insertData($offset, $arg) { --- 107,117 ---- /** * Takes a string, splits the data attributes current contents at the given ! * offset, then inserts the string arg between the two substrings.<br> * DOM-Level 1 * * @public ! * @param $offset <code>int</code> ! * @param $arg <code>string</code> ! * @returns string */ function insertData($offset, $arg) { *************** *** 120,128 **** /** ! * Replaces a substring within the data attribute with another string. * DOM-Level 1 * * @public ! * @return string */ function replaceData($offset, $count, $arg) { --- 121,132 ---- /** ! * Replaces a substring within the data attribute with another string.<br> * DOM-Level 1 * * @public ! * @param $offset <code>int</code> ! * @param $count <code>int</code> ! * @param $arg <code>string</code> ! * @returns string */ function replaceData($offset, $count, $arg) { *************** *** 137,145 **** /** * Returns a string that contains a subset of the string stored in the data ! * attribute. * DOM-Level 1 * * @public ! * @return string */ function substringData($offset, $count) { --- 141,151 ---- /** * Returns a string that contains a subset of the string stored in the data ! * attribute.<br> * DOM-Level 1 * * @public ! * @param $offset <code>int</code> ! * @param $count <code>int</code> ! * @returns string */ function substringData($offset, $count) { Index: comment.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/comment.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** comment.php 2001/06/21 18:59:42 1.1.1.1 --- comment.php 2001/11/27 20:32:34 1.2 *************** *** 14,33 **** * @version $Revision$ */ ! class Comment extends CharacterData ! { ! ! /** ! * Constructor of the class. ! * ! * @access public ! */ ! function Comment() ! { ! CharacterData::CharacterData(); ! $this->nodeName = "#comment"; ! $this->nodeType = COMMENT_NODE; ! } ! } - ?> --- 14,28 ---- * @version $Revision$ */ ! class Comment extends CharacterData { ! /** ! * Constructor of the class. ! * ! * @public ! */ ! function Comment() { ! CharacterData::CharacterData(); ! $this->nodeName = "#comment"; ! $this->nodeType = COMMENT_NODE; ! } } ?> Index: document.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/document.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** document.php 2001/06/28 22:24:23 1.3 --- document.php 2001/11/27 20:32:34 1.4 *************** *** 14,437 **** * @version $Revision$ */ ! class Document extends Node ! { ! /** ! * An instance of the DocumentType interface representing the DTD. If no ! * DTD was declared in the document, this property is null. ! * DOM-Level 1 ! * ! * @access protected ! * @var DocumentType ! */ ! var $doctype; ! ! /** ! * Points to the single Element node that is the root of the XML tree. ! * DOM-Level 1 ! * ! * @access protected ! * @var Element ! */ ! var $documentElement; ! ! /** ! * An reference to the DOMImplementation that is responsible for this ! * document. ! * DOM-Level 1 ! * ! * @access protected ! * @var DOMImplementation ! */ ! var $implementation; ! ! /** ! * Constructor of the class. ! * ! * @access public ! */ ! function Document() ! { ! Node::Node(); ! $this->nodeType = DOCUMENT_NODE; ! $this->nodeName = "#document"; ! } ! ! /** ! * Returns an reference to the DocumentType object. ! * DOM-Level 1 ! * ! * @access public ! * @return DocumentType ! */ ! function &getDoctype() ! { ! return $this->doctype; ! } ! ! /** ! * Returns an reference to the root element. ! * DOM-Level 1 ! * ! * @access public ! * @return Element ! */ ! function &getDocumentElement() ! { ! return $this->documentElement; ! } ! ! /** ! * Returns an reference to the DOMImplementation object. ! * DOM-Level 1 ! * ! * @access public ! * @return DOMImplementation ! */ ! function &getImplementation() ! { ! return $this->implementation; ! } ! ! /** ! * Creates an Attribute node. ! * DOM-Level 1 ! * ! * @access public ! * @var string $name ! * @return Attr ! */ ! function &createAttribute($name) ! { ! $new = new Attr(); ! $new->nodeName = $name; ! $new->setValue($value); ! $new->ownerElement = NULL; ! $new->ownerDocument =& $this; ! return $new; ! } ! ! /** ! * Creates a CDataSection node. ! * DOM-Level 1 ! * ! * @access public ! * @var string $data ! * @return CDataSection ! */ ! function &createCDataSection($data) ! { ! $new = new CDataSection(); ! $new->nodeValue = $data; ! $new->ownerDocument = &$this; ! return $new; ! } ! ! /** ! * Creates a Comment node. ! * DOM-Level 1 ! * ! * @access public ! * @var string $data ! * @return Comment ! */ ! function &createComment($data) ! { ! $new = new Comment(); ! $new->nodeValue = $data; ! $new->ownerDocument = &$this; ! return $new; ! } ! ! /** ! * Creates a DocumentFragment node ! * DOM-Level 1 ! * ! * @access public ! * @return DocumentFragment ! */ ! function &createDocumentFragment() ! { ! $new = new DocumentFragment(); ! return $new; ! } ! ! /** ! * Creates an Element node ! * DOM-Level 1 ! * ! * @access public ! * @var string $tagName ! * @return Element ! */ ! function &createElement($tagName) ! { ! $new = new Element(); ! $new->nodeName = $tagName; ! $new->ownerDocument = &$this; ! return $new; ! } ! ! /** ! * Creates an EntityReference node (not supported yet) ! * DOM-Level 1 ! * ! * @access public ! * @var string $name ! * @return EntityReference ! */ ! function &createEntityReference($name) ! { ! return NOT_SUPPORTED_ERR; ! } ! ! /** ! * Creates a ProcessingInstruction node. ! * DOM-Level 1 ! * ! * @access public ! * @var string $target ! * @var string $data ! * @return ProcessingInstruction ! */ ! function &createProcessingInstruction($target, $data) ! { ! $new = new ProcessingInstruction(); ! $new->nodeValue = $data; ! $new->nodeName = $target; ! $new->ownerDocument = &$this; ! return $new; ! } ! ! /** ! * Creates a Text node. ! * DOM-Level 1 ! * ! * @access public ! * @var string $data ! * @return Text ! */ ! function &createTextNode($data) ! { ! $new = new Text(); ! $new->nodeValue = $data; ! $new->ownerDocument = &$this; ! return $new; ! } ! ! /** ! * Returns a NodeList of Element nodes from the current document whose ! * tagName attribute matches the given tagname. ! * DOM-Level 1 ! * ! * @access public ! * @var string $tagName ! * @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; ! } ! ! /** ! * 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; ! } ! ! /** ! * 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 ! * @var Node $importedNode ! * @var boolean $deep ! * @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; ! } ! ! /** ! * Runs recursively through the DOM-Tree and returns a NodeList with all ! * Element nodes that have the searched tagname. ! * ! * @access private ! * @var string $tagName ! * @var Node $parent ! * @var NodeList $result ! */ ! function getElementsByTagNameList($tagName, &$parent, &$result) ! { ! if ($parent->nodeType == ELEMENT_NODE) ! { ! if (($parent->tagName == $tagName) || ($tagName == "*")) ! { ! $result->insertNode($parent); ! } ! ! if ($parent->hasChildNodes()) ! { ! $this->getElementsByTagNameList($tagName, $parent->firstChild, $result); ! } ! } ! ! if (isset($parent->nextSibling)) ! { ! $this->getElementsByTagNameList($tagName, $parent->nextSibling, $result); ! } ! } ! ! /** ! * 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); ! } ! } ! } - ?> --- 14,422 ---- * @version $Revision$ */ ! class Document extends Node { ! /** ! * An instance of the DocumentType interface representing the DTD; If no ! * DTD was declared in the document, this property is null.<br> ! * DOM-Level 1 ! * ! * @private ! * @type DocumentType ! */ ! var $doctype; ! ! /** ! * Points to the single Element node that is the root of the XML tree.<br> ! * DOM-Level 1 ! * ! * @private ! * @type Element ! */ ! var $documentElement; ! ! /** ! * An reference to the DOMImplementation that is responsible for this ! * document.<br> ! * DOM-Level 1 ! * ! * @private ! * @type DOMImplementation ! */ ! var $implementation; ! ! /** ! * Constructor of the class.<br> ! * ! * @public ! */ ! function Document() { ! Node::Node(); ! $this->nodeType = DOCUMENT_NODE; ! $this->nodeName = "#document"; ! } ! ! /** ! * Returns an reference to the DocumentType object.<br> ! * DOM-Level 1 ! * ! * @public ! * @returns DocumentType ! */ ! function &getDoctype() { ! return $this->doctype; ! } ! ! /** ! * Returns an reference to the root element.<br> ! * DOM-Level 1 ! * ! * @public ! * @returns Element ! */ ! function &getDocumentElement() { ! return $this->documentElement; ! } ! ! /** ! * Returns an reference to the DOMImplementation object.<br> ! * DOM-Level 1 ! * ! * @public ! * @returns DOMImplementation ! */ ! function &getImplementation() { ! return $this->implementation; ! } ! ! /** ! * Creates an Attribute node.<br> ! * DOM-Level 1 ! * ! * @public ! * @param $name <code>string</code> ! * @param $value <code>string</code> ! * @returns Attr ! */ ! function &createAttribute($name) { ! $new = new Attr(); ! $new->nodeName = $name; ! $new->ownerElement = NULL; ! $new->ownerDocument =& $this; ! return $new; ! } ! ! /** ! * Creates a CDataSection node.<br> ! * DOM-Level 1 ! * ! * @public ! * @param $data ! * @returns CDataSection ! */ ! function &createCDataSection($data) { ! $new = new CDataSection(); ! $new->nodeValue = $data; ! $new->ownerDocument = &$this; ! return $new; ! } ! ! /** ! * Creates a Comment node.<br> ! * DOM-Level 1 ! * ! * @public ! * @param $data <code>string</code> ! * @returns Comment ! */ ! function &createComment($data) { ! $new = new Comment(); ! $new->nodeValue = $data; ! $new->ownerDocument = &$this; ! return $new; ! } ! ! /** ! * Creates a DocumentFragment node.<br> ! * DOM-Level 1 ! * ! * @public ! * @returns DocumentFragment ! */ ! function &createDocumentFragment() { ! $new = new DocumentFragment(); ! return $new; ! } ! ! /** ! * Creates an Element node.<br> ! * DOM-Level 1 ! * ! * @public ! * @param $tagName <code>string</code> ! * @returns Element ! */ ! function &createElement($tagName) { ! $new = new Element(); ! $new->nodeName = $tagName; ! $new->ownerDocument = &$this; ! return $new; ! } ! ! /** ! * Creates an EntityReference node (not supported yet)<br> ! * DOM-Level 1 ! * ! * @public ! * @param $name <code>string</code> ! * @returns EntityReference ! */ ! function &createEntityReference($name) { ! return NOT_SUPPORTED_ERR; ! } ! ! /** ! * Creates a ProcessingInstruction node.<br> ! * DOM-Level 1 ! * ! * @public ! * @param $target <code>string</code> ! * @param $data <code>string</code> ! * @returns ProcessingInstruction ! */ ! function &createProcessingInstruction($target, $data) { ! $new = new ProcessingInstruction(); ! $new->nodeValue = $data; ! $new->nodeName = $target; ! $new->ownerDocument = &$this; ! return $new; ! } ! ! /** ! * Creates a Text node.<br> ! * DOM-Level 1 ! * ! * @public ! * @param $data <code>string</code> ! * @returns Text ! */ ! function &createTextNode($data) { ! $new = new Text(); ! $new->nodeValue = $data; ! $new->ownerDocument = &$this; ! return $new; ! } ! ! /** ! * Returns a NodeList of Element nodes from the current document whose ! * tagName attribute matches the given tagname.<br> ! * DOM-Level 1 ! * ! * @public ! * @param $tagName <code>string</code> ! * @returns NodeList ! */ ! function &getElementsByTagName($tagName) { ! $result = new NodeList(); ! $this->getElementsByTagNameList($tagName, $this->documentElement, $result); ! return $result; ! } ! ! /** ! * Same as createAttribute, but includes support for XML namespaces.<br> ! * DOM-Level 2 ! * ! * @public ! * @param $namespaceURI <code>string</code> ! * @param $qualifiedName <code>string</code> ! * @returns 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.<br> ! * DOM-Level 2 ! * ! * @public ! * @param $namespaceURI <code>string</code> ! * @param $qualifiedName <code>string</code> ! * @returns 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.<br> ! * DOM-Level 2 -- NYI ! * ! * @public ! * @param $elementID <code>string</code> ! * @returns Element ! */ ! function &getElementById($elementID) { ! // This could not be implemented, as long as the DTD is not parsed. ! return NOT_SUPPORTED_ERR; ! } ! ! /** ! * Same as getElementByTagName, but includes support for XML namespaces.<br> ! * DOM-Level 2 ! * ! * @public ! * @param $namespaceURI <code>string</code> ! * @param $localName <code>string</code> ! * @returns NodeList ! */ ! function &getElementsByTagNameNS($namespaceURI, $localName) { ! $result = new NodeList(); ! $this->getElementsByTagNameNSList($namespaceURI, $localName, ! $this->documentElement, $result); ! return $result; ! } ! ! /** ! * Creates a copy of a Node object from another document that can be ! * inserted within the current documents node hierarchy.<br> ! * DOM-Level 2 ! * ! * @public ! * @param $importedNode <a href="Node.html">Node</a> ! * @param $deep <code>boolean</code> ! * @returns 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; ! } ! ! /** ! * Runs recursively through the DOM-Tree and returns a NodeList with all ! * Element nodes that have the searched tagname. ! * ! * @private ! * @param $tagName <code>string</code> ! * @param $parent <a href="Node.html">Node</a> ! * @param $result <a href="NodeList.html">NodeList</a> ! * @returns void ! */ ! function getElementsByTagNameList($tagName, &$parent, &$result) { ! if ($parent->nodeType == ELEMENT_NODE) { ! if (($parent->tagName == $tagName) || ($tagName == "*")) { ! $result->insertNode($parent); ! } ! ! if ($parent->hasChildNodes()) { ! $this->getElementsByTagNameList($tagName, $parent->firstChild, ! $result); ! } ! } ! ! if (isset($parent->nextSibling)) { ! $this->getElementsByTagNameList($tagName, $parent->nextSibling, $result); ! } ! } ! ! /** ! * Runs recursively through the DOM-Tree and returns a NodeList with all ! * Element nodes that have the searched $namespaceURI and $localName. ! * ! * @private ! * @param $namespaceURI <code>string</code> ! * @param $localName <code>string</code> ! * @param $parent <a href="Node.html">Node</a> ! * @param $result <a href="NodeList.html">NodeList</a> ! * @returns void ! */ ! 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: documentfragment.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/documentfragment.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** documentfragment.php 2001/06/21 18:59:47 1.1.1.1 --- documentfragment.php 2001/11/27 20:32:34 1.2 *************** *** 14,33 **** * @version $Revision$ */ ! class DocumentFragment extends Node ! { ! ! /** ! * Constructor of the class. ! * ! * @access public ! */ ! function DocumentFragment() ! { ! Node::Node(); ! $this->nodeType = DOCUMENT_FRAGMENT_NODE; ! $this->nodeName = "#document-fragment"; ! } ! } - ?> --- 14,28 ---- * @version $Revision$ */ ! class DocumentFragment extends Node { ! /** ! * Constructor of the class. ! * ! * @public ! */ ! function DocumentFragment() { ! Node::Node(); ! $this->nodeType = DOCUMENT_FRAGMENT_NODE; ! $this->nodeName = "#document-fragment"; ! } } ?> Index: documenttype.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/documenttype.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** documenttype.php 2001/06/21 21:59:29 1.2 --- documenttype.php 2001/11/27 20:32:34 1.3 *************** *** 14,163 **** * @version $Revision$ */ ! class DocumentType extends Node ! { ! /** ! * A list of all generall entities declared in the DTD. ! * DOM-Level 1-- NYI ! * ! * @access protected ! * @var string ! */ ! var $entities; ! ! /** ! * The name of the DTD. ! * DOM-Level 1 ! * ! * @access protected ! * @var string ! */ ! var $name; ! ! /** ! * Contains a list of XML notation declarations. ! * DOM-Level 1 -- NYI ! * ! * @access protected ! * @var string ! */ ! var $notations; ! ! /** ! * Contains the documents internat subset as a string value. ! * DOM-Level 2 ! * ! * @access protected ! * @var string ! */ ! var $internalSubset; ! ! /** ! * The public identifier of the external subset. ! * DOM-Level 2 ! * ! * @access protected ! * @var string ! */ ! var $publicId; ! ! /** ! * The system identifier of the external subset. ! * DOM-Level 2 ! * ! * @access protected ! * @var string ! */ ! var $systemId; ! ! /** ! * Constructor of the class. ! * ! * @access public ! */ ! function DocumentType() ! { ! Node::Node(); ! $this->nodeType = DOCUMENT_TYPE_NODE; ! $this->name =& $this->nodeName; ! ! //$notation = new NamedNodeMap(); ! //$entities = new NamedNodeMap(); ! } ! ! /** ! * Returns a NameNodeMap containing all general entities declared in the ! * DTD. ! * DOM-Level 1 -- NYI ! * ! * @access public ! * @return NameNodeMap ! */ ! function getEntities() ! { ! return NOT_SUPPORTED_ERR; ! } ! ! /** ! * Returns the internal subset. ! * DOM-Level 2 ! * ! * @access public ! * @return string ! */ ! function getInternalSubset() ! { ! return $this->internalSubset; ! } ! ! /** ! * Returns the name of the DTD. ! * DOM-Level 1 ! * ! * @access public ! * @return string ! */ ! function getName() ! { ! return $this->name; ! } ! ! /** ! * Returns a NameNodeMap containing all notations declared in the ! * DTD. ! * DOM-Level 1 -- NYI ! * ! * @access public ! * @return NameNodeMap ! */ ! function getNotations() ! { ! return NOT_SUPPORTED_ERR; ! } ! ! /** ! * Returns the public identifier of an external subset. ! * DOM-Level 2 ! * ! * @access public ! * @return string ! */ ! function getPublicId() ! { ! return $this->publicId; ! } ! ! /** ! * Returns the system identifier of an external subset. ! * DOM-Level 2 ! * ! * @access public ! * @return string ! */ ! function getSystemId() ! { ! return $this->systemId; ! } ! } - ?> --- 14,153 ---- * @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; ! ! /** ! * The name of the DTD.<br> ! * DOM-Level 1 ! * ! * @private ! * @type string ! */ ! var $name; ! ! /** ! * Contains a list of XML notation declarations.<br> ! * DOM-Level 1 -- NYI ! * ! * @private ! * @type string ! */ ! var $notations; ! ! /** ! * Contains the documents internat subset as a string value.<br> ! * DOM-Level 2 ! * ! * @private ! * @type string ! */ ! var $internalSubset; ! ! /** ! * The public identifier of the external subset.<br> ! * DOM-Level 2 ! * ! * @private ! * @type string ! */ ! var $publicId; ! ! /** ! * The system identifier of the external subset.<br> ! * DOM-Level 2 ! * ! * @private ! * @type string ! */ ! var $systemId; ! ! /** ! * Constructor of the class.<br> ! * ! * @public ! */ ! function DocumentType() { ! Node::Node(); ! $this->nodeType = DOCUMENT_TYPE_NODE; ! $this->name =& $this->nodeName; ! ! //$notation = new NamedNodeMap(); ! //$entities = new NamedNodeMap(); ! } ! ! /** ! * 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; ! } ! ! /** ! * Returns the internal subset.<br> ! * DOM-Level 2 ! * ! * @public ! * @returns string ! */ ! function getInternalSubset() { ! return $this->internalSubset; ! } ! ! /** ! * Returns the name of the DTD.<br> ! * DOM-Level 1 ! * ! * @public ! * @returns string ! */ ! function getName() { ! return $this->name; ! } ! ! /** ! * Returns a NamedNodeMap containing all notations declared in the ! * DTD.<br> ! * DOM-Level 1 -- NYI ! * ! * @public ! * @returns NamedNodeMap ! */ ! function getNotations() { ! return NOT_SUPPORTED_ERR; ! } ! ! /** ! * Returns the public identifier of an external subset.<br> ! * DOM-Level 2 ! * ! * @public ! * @returns string ! */ ! function getPublicId() { ! return $this->publicId; ! } ! ! /** ! * Returns the system identifier of an external subset.<br> ! * DOM-Level 2 ! * ! * @public ! * @returns string ! */ ! function getSystemId() { ! return $this->systemId; ! } } ?> Index: domexception.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/domexception.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** domexception.php 2001/06/25 21:15:34 1.2 --- domexception.php 2001/11/27 20:32:34 1.3 *************** *** 16,20 **** /** ! * If index or size is negative, or greater than the allowed value. * DOM-Level 1 * --- 16,20 ---- /** ! * If index or size is negative, or greater than the allowed value.<br> * DOM-Level 1 * *************** *** 24,28 **** /** ! * If the specified range of text does not fit into a DOMString. * DOM-Level 1 * --- 24,28 ---- /** ! * If the specified range of text does not fit into a DOMString.<br> * DOM-Level 1 * *************** *** 32,36 **** /** ! * If any node is inserted somewhere it doesn't belong. * DOM-Level 1 * --- 32,36 ---- /** ! * If any node is inserted somewhere it doesn't belong.<br> * DOM-Level 1 * *************** *** 40,44 **** /** ! * If a node is used in a different document than the one that created it (that doesn't support it). * DOM-Level 1 * --- 40,45 ---- /** ! * If a node is used in a different document than the one ! * that created it (that doesn't support it).<br> * DOM-Level 1 * *************** *** 48,52 **** /** ! * If an invalid or illegal character is specified, such as in a name. * DOM-Level 1 * --- 49,53 ---- /** ! * If an invalid or illegal character is specified, such as in a name. <br> * DOM-Level 1 * *************** *** 56,60 **** /** ! * If data is specified for a node which does not support data. * DOM-Level 1 * --- 57,61 ---- /** ! * If data is specified for a node which does not support data.<br> * DOM-Level 1 * *************** *** 64,68 **** /** ! * If an attempt is made to modify an object where modifications are not allowed. * DOM-Level 1 * --- 65,70 ---- /** ! * If an attempt is made to modify an object where modifications ! * are not allowed.<br> * DOM-Level 1 * *************** *** 72,76 **** /** ! * If an attempt is made to reference a node in a context where it does not exist. * DOM-Level 1 * --- 74,79 ---- /** ! * If an attempt is made to reference a node in a context where ! * it does not exist.<br> * DOM-Level 1 * *************** *** 80,84 **** /** ! * If the implementation does not support the requested type of object or operation. * DOM-Level 1 * --- 83,88 ---- /** ! * If the implementation does not support the requested type of object ! * or operation.<br> * DOM-Level 1 * *************** *** 88,92 **** /** ! * If an attempt is made to add an attribute that is already in use elsewhere. * DOM-Level 1 * --- 92,97 ---- /** ! * If an attempt is made to add an attribute that is already in ! * use elsewhere.<br> * DOM-Level 1 * *************** *** 96,100 **** /** ! * If an attempt is made to use an object that is not, or is no longer, usable. * DOM-Level 2 * --- 101,106 ---- /** ! * If an attempt is made to use an object that is not, or is no ! * longer, usable.<br> * DOM-Level 2 * *************** *** 104,108 **** /** ! * If an invalid or illegal string is specified. * DOM-Level 2 * --- 110,114 ---- /** ! * If an invalid or illegal string is specified.<br> * DOM-Level 2 * *************** *** 112,116 **** /** ! * If an attempt is made to modify the type of the underlying object. * DOM-Level 2 * --- 118,122 ---- /** ! * If an attempt is made to modify the type of the underlying object.<br> * DOM-Level 2 * *************** *** 120,124 **** /** ! * If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces. * DOM-Level 2 * --- 126,131 ---- /** ! * 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 * *************** *** 128,132 **** /** ! * If a parameter or an operation is not supported by the underlying object. * DOM-Level 2 * --- 135,139 ---- /** ! * If a parameter or an operation is not supported by the underlying object.<br> * DOM-Level 2 * Index: domimplementation.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/domimplementation.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** domimplementation.php 2001/06/28 22:24:23 1.2 --- domimplementation.php 2001/11/27 20:32:34 1.3 *************** *** 14,124 **** * @version $Revision$ */ ! class DOMImplementation ! { ! ! /** ! * Tests to see if the DOM implementation supports a given named feature ! * package. ! * DOM-Level 1 ! * ! * @access public ! * @var string $feature ! * @var string $version ! * @return boolean ! */ ! function hasFeature($feature, $version) ! { ! if (($feature == "XML") || ($feature == "Core")) ! { ! if ($version == "1.0") ! { ! return true; ! } ! } ! return false; ! } ! ! /** ! * Creates a new, empty Document with the given document type. ! * DOM-Level 2 ! * ! * @access public ! * @var string $namespaceURI ! * @var string $qualifiedName ! * @var DocumentType $doctype ! * @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; ! } ! ! /** ! * Creates an empty DocumentType node that is not associated with any ! * document. ! * DOM-Level 2 ! * ! * @access public ! * @var string $qualifiedName ! * @var string $publicId ! * @var string $systemId ! * @return DocumentType ! */ ! 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; ! } ! } - ?> --- 14,119 ---- * @version $Revision$ */ ! class DOMImplementation { ! /** ! * Tests to see if the DOM implementation supports a given named feature ! * package.<br> ! * DOM-Level 1 ! * ! * @public ! * @param $feature <code>string</code> ! * @param $version <code>string</code> ! * @returns boolean ! */ ! function hasFeature($feature, $version) { ! if (($feature == "XML") || ($feature == "Core")) { ! if ($version == "1.0") { ! return true; ! } ! } ! return false; ! } ! ! /** ! * Creates a new, empty Document with the given document type.<br> ! * DOM-Level 2 ! * ! * @public ! * @param $namespaceURI <code>string</code> ! * @param $qualifiedName <code>string</code> ! * @param $doctype <a href="DocumentType.html">DocumentType</a> ! * @returns 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; ! } ! ! /** ! * Creates an empty DocumentType node that is not associated with any ! * document.<br> ! * DOM-Level 2 ! * ! * @public ! * @param $qualifiedName <code>string</code> ! * @param $publicId <code>string</code> ! * @param $systemId <code>string</code> ! * @returns DocumentType ! */ ! 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: element.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/include/element.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** element.php 2001/07/09 19:04:16 1.3 --- element.php 2001/11/27 20:32:34 1.4 *************** *** 14,415 **** * @version $Revision$ */ ! class Element extends Node ! { ! /** ! * The XML tag name. ! * DOM-Level 1 ! * ! * @access protected ! * @var string ! */ ! var $tagName; ! ! /** ! * Constructor of the class. ! * ! * @access public ! */ ! function Element() ! { ! $this->Node(); ! $this->nodeType = ELEMENT_NODE; ! $this->tagName =& $this->nodeName; ! } ! ! /** ! * Returns the XML tag name of the element. ! * DOM-Level 1 ! * ! * @access public ! * @return string ! */ ! function getTagName() ! { ! return $this->tagName; ! } ! ! /** ! * Returns the value of the attribute specified by the name parameter. ! * DOM-Level 1 ! * ! * @access public ! * @var string $name ! * @return string ! */ ! function getAttribute($name) ! { ! $attr =& $this->getAttributeNode($name); ! return $attr->getValue(); ! } ! ! /** ! * Returns the attribute specified by the name parameter. ! * DOM-Level 1 ! * ! * @access public ! * @var string $name ! * @return Attr ! */ ! function &getAttributeNode($name) ! { ! if (isset($this->attributes)) ! { ! return $this->attributes->getNamedItem($name); ! } ! } ! ! /** ! * Returns a NodeList of all child Element nodes whose tagName attribute ! * matches the give name parameter. ! * DOM-Level 1 ! * ! * @access public ! * @var string $name ! * @return NodeList ! */ ! function &getElementsByTagName($name) ! { ! $result = new NodeList(); ! $this->getElementsByTagNameList($name, $this->firstChild, $result); ! return $result; ! } ! ! /** ! * Removes the Attribute node specified by name. ! * DOM-Level 1 ! * ! * @access public ! * @var string $name ! */ ! function removeAttribute($name) ! { ! if (isset($this->attributes)) ! { ! $this->attributes->removeNamedItem($name); ! } ! } ! ! /** ! * Removes the specified Attribute node. ! * DOM-Level 1 ! * ! * @access public ! * @var Attr $oldAttr ! * @return Attr ! */ ! function &removeAttributeNode(&$oldAttr) ! { ! if (isset($this->attributes)) ! { ! return $this->attributes->removeNamedItem($oldAttr->nodeName); ! } ! } ! ! /** ! * Set the Attribute name to the value. If the node does not exist, it is ! * created. ! * DOM-Level 1 ! * ! * @access public ! * @var string $name ! * @var string $value ! */ ! function setAttribute($name, $value) ! { ! $new = new Attr(); ! $new->nodeName = $name; ! $new->setValue($value); ! $new->ownerElement = &$this; ! $new->ownerDocument = &$this->ownerDocument; ! ! if (empty($this->attributes)) ! { ! $this->attributes = new NamedNodeMap(); ! } ! ! $this->attributes->setNamedItem($new); ! } ! ! /** ! * Sets the specified Attribute node. ! * DOM-Level 1 ! * ! * @access public ! * @var Attr $newAttr ! * @return Attr ! */ ! function &setAttributeNode(&$newAttr) ! { ! if (empty($this->attributes)) ! { ! $this->attributes = new NamedNodeMap(); ! } ! ! return $this->attributes->setNamedItem($newAttr); ! } ! ! /** ! * 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); ! } ! ! /** ! * Runs recursively through the DOM-Tree and returns a NodeList with all ! * Element nodes that have the searched tagname. ! * ! * @access private ! * @var string $tagName ! * @var Node $parent ! * @var NodeList $result ! */ ! function getElementsByTagNameList($tagName, &$parent, &$result) ! { ! if ($parent->nodeType == ELEMENT_NODE) ! { ! if (($parent->tagName == $tagName) || ($tagName == "*")) ! { ! $result->insertNode($parent); ! } ! ! if ($parent->hasChildNodes()) ! { ! $this->getElementsByTagNameList($tagName, $parent->firstChild, $result); ! } ! } ! ! if (isset($parent->nextSibling)) ! { ! $this->getElementsByTagNameList($tagName, $parent->nextSibling, $result); ! } ! } ! ! /** ! * 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); ! } ... [truncated message content] |
|
From: Thomas D. <th...@us...> - 2001-11-26 23:39:30
|
Update of /cvsroot/phpxd/phpXD/include
In directory usw-pr-cvs1:/tmp/cvs-serv12523/include
Modified Files:
cdatasection.php characterdata.php
Log Message:
Changed source documentation for using PHPDoc.
Index: cdatasection.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/cdatasection.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** cdatasection.php 2001/06/21 18:59:42 1.1.1.1
--- cdatasection.php 2001/11/26 23:39:27 1.2
***************
*** 16,33 ****
class CDataSection extends Text
{
!
! /**
! * Constructor of the class.
! *
! * @access public
! */
! function CDataSection()
! {
! Text::Text();
! $this->nodeType = CDATA_SECTION_NODE;
! $this->nodeName = "#cdata-section";
! }
!
}
-
?>
--- 16,29 ----
class CDataSection extends Text
{
! /**
! * Constructor of the class.
! *
! * @public
! */
! function CDataSection() {
! Text::Text();
! $this->nodeType = CDATA_SECTION_NODE;
! $this->nodeName = "#cdata-section";
! }
}
?>
Index: characterdata.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/characterdata.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** characterdata.php 2001/06/21 18:59:45 1.1.1.1
--- characterdata.php 2001/11/26 23:39:27 1.2
***************
*** 16,158 ****
class CharacterData extends Node
{
! /**
! * The "raw" data of the CharacterData node.
! * DOM-Level 1
! *
! * @access protected
! * @var string
! */
! var $data;
!
! /**
! * The size of the string stored in data.
! * DOM-Level 1
! *
! * @access protected
! * @var int
! */
! var $length;
!
! /**
! * Constructor of the class.
! *
! * @access public
! */
! function CharacterData()
! {
! Node::Node();
! $this->data =& $this->nodeValue;
! }
!
! /**
! * Returns the data stored in this node.
! * DOM-Level 1
! *
! * @access public
! * @return string
! */
! function getData()
! {
! return $this->data;
! }
!
! /**
! * Sets the data stored in this node.
! * DOM-Level 1
! *
! * @access public
! * @var string $data
! * @return string
! */
! function setData($data)
! {
! $this->nodeValue = $data;
! }
!
! /**
! * Returns the length of the data stored in this node.
! * DOM-Level 1
! *
! * @access public
! * @return string
! */
! function getLength()
! {
! return strlen($this->data);
! }
!
! /**
! * Appends contents of the arg parameter to the current contents of the data
! * attribute.
! * DOM-Level 1
! *
! * @access public
! * @var string $arg
! * @return string
! */
! function appendData($arg)
! {
! $this->nodeValue .= $arg;
! }
!
! /**
! * Truncates the data attribute. It removes count characters, starting at
! * the offset position.
! * DOM-Level 1
! *
! * @access public
! * @var int $offset
! * @var int $count
! * @return string
! */
! function deleteData($offset, $count)
! {
! $this->nodeValue = substr($this->nodeValue, 0, $offset-1) . substr($this->nodeValue, $offset+count);
! }
!
! /**
! * Takes a string, splits the data attributes current contents at the given
! * offset, then inserts the string arg between the two substrings.
! * DOM-Level 1
! *
! * @access public
! * @return string
! */
! function insertData($offset, $arg)
! {
! $this->nodeValue = substr($this->nodeValue, 0, $offset-1) . $arg . substr($this->nodeValue, $offset);
! }
!
! /**
! * Replaces a substring within the data attribute with another string.
! * DOM-Level 1
! *
! * @access public
! * @return string
! */
! function replaceData($offset, $count, $arg)
! {
! if ($offset + $count > strlen($this->nodeValue))
! {
! $count = strlen($this->nodeValue) - $offset;
! }
!
! $this->nodeValue = substr($this->nodeValue, 0, $offset-1) . substr($arg, 0, $count) . substr($this->nodeValue, $offset+$count);
! }
!
! /**
! * Returns a string that contains a subset of the string stored in the data
! * attribute.
! * DOM-Level 1
! *
! * @access public
! * @return string
! */
! function substringData($offset, $count)
! {
! return substr($this->nodeValue, $offset, $count);
! }
!
}
-
?>
--- 16,149 ----
class CharacterData extends Node
{
! /**
! * The "raw" data of the CharacterData node.
! * DOM-Level 1
! *
! * @private
! * @type string
! */
! var $data;
!
! /**
! * The size of the string stored in data.
! * DOM-Level 1
! *
! * @private
! * @type int
! */
! var $length;
!
! /**
! * Constructor of the class.
! *
! * @public
! */
! function CharacterData() {
! Node::Node();
! $this->data =& $this->nodeValue;
! }
!
! /**
! * Returns the data stored in this node.
! * DOM-Level 1
! *
! * @public
! * @return string
! */
! function getData() {
! return $this->data;
! }
!
! /**
! * Sets the data stored in this node.
! * DOM-Level 1
! *
! * @public
! * @param $data
! * @return string
! */
! function setData($data) {
! $this->nodeValue = $data;
! }
!
! /**
! * Returns the length of the data stored in this node.
! * DOM-Level 1
! *
! * @public
! * @return string
! */
! function getLength() {
! return strlen($this->data);
! }
!
! /**
! * Appends contents of the arg parameter to the current contents of the data
! * attribute.
! * DOM-Level 1
! *
! * @public
! * @param $arg
! * @return string
! */
! function appendData($arg) {
! $this->nodeValue .= $arg;
! }
!
! /**
! * Truncates the data attribute. It removes count characters, starting at
! * the offset position.
! * DOM-Level 1
! *
! * @public
! * @param $offset
! * @param $count
! * @return string
! */
! function deleteData($offset, $count) {
! $this->nodeValue = substr($this->nodeValue, 0, $offset-1).
! substr($this->nodeValue, $offset+count);
! }
!
! /**
! * Takes a string, splits the data attributes current contents at the given
! * offset, then inserts the string arg between the two substrings.
! * DOM-Level 1
! *
! * @public
! * @return string
! */
! function insertData($offset, $arg) {
! $this->nodeValue = substr($this->nodeValue, 0, $offset-1).$arg.
! substr($this->nodeValue, $offset);
! }
!
! /**
! * Replaces a substring within the data attribute with another string.
! * DOM-Level 1
! *
! * @public
! * @return string
! */
! function replaceData($offset, $count, $arg) {
! if ($offset + $count > strlen($this->nodeValue)) {
! $count = strlen($this->nodeValue) - $offset;
! }
!
! $this->nodeValue = substr($this->nodeValue, 0, $offset-1).
! substr($arg, 0, $count) . substr($this->nodeValue, $offset+$count);
! }
!
! /**
! * Returns a string that contains a subset of the string stored in the data
! * attribute.
! * DOM-Level 1
! *
! * @public
! * @return string
! */
! function substringData($offset, $count) {
! return substr($this->nodeValue, $offset, $count);
! }
}
?>
|
|
From: Thomas D. <th...@us...> - 2001-11-26 21:27:39
|
Update of /cvsroot/phpxd/phpXD
In directory usw-pr-cvs1:/tmp/cvs-serv4802
Modified Files:
sample.php
Log Message:
Coding style a litte bit changed.
Index: sample.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/sample.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** sample.php 2001/07/11 21:53:37 1.3
--- sample.php 2001/11/26 21:27:36 1.4
***************
*** 14,175 ****
* @author Thomas Dohmke <th...@do...>
* @version $Revision$
- * @access public
*/
require("phpXD.php");
! function echoTree(&$dom, $deep = 0)
! {
! $space = "";
! for ($i = 0; $i < $deep; $i++) $space .= " ";
! if ($dom->nodeType == CDATA_SECTION_NODE)
! {
! echo $space;
! echo "<span style=\"color:#990000\">";
! echo "<![CDATA[";
! $output = htmlspecialchars($dom->getData());
! if (!(strpos($output, "\n") === false))
! {
! $break = "<br />";
! }
! else
! {
! $break = "";
! $space = "";
! }
! echo $break.$space;
! $output = str_replace(" ", " ", $output);
! $output = str_replace("\n", "<br />".$space, $output);
! $output = str_replace("\t", " ", $output);
! echo $output;
! echo $break.$space;
! echo "]]><br />";
! echo "</span>";
! }
! if ($dom->nodeType == COMMENT_NODE)
! {
! echo $space;
! echo "<span style=\"color:#009900\">";
! echo "<!--";
! $output = htmlspecialchars($dom->getData());
! if (!(strpos($output, "\n") === false))
! {
! $break = "<br />";
! }
! else
! {
! $break = "";
! $space = "";
! }
! echo $break.$space;
! $output = str_replace(" ", " ", $output);
! $output = str_replace("\n", "<br />".$space, $output);
! $output = str_replace("\t", " ", $output);
! echo $output;
! echo $break.$space;
! echo "--><br />";
! echo "</span>";
! }
! if ($dom->nodeType == DOCUMENT_NODE)
! {
! echo "<pre>";
! if (!empty($dom->doctype))
! {
! if (!empty($dom->doctype->publicId) && !empty($dom->doctype->systemId))
! {
! echo "<!DOCTYPE ".$dom->doctype->name." PUBLIC ".$dom->doctype->systemId." ".$dom->doctype->publicId.">\n";
! }
! else
! if (!empty($dom->doctype->systemId))
! {
! echo "<!DOCTYPE ".$dom->doctype->name." SYSTEM ".$dom->doctype->systemId.">\n";
! }
! else
! {
! $output = $dom->doctype->internalSubset;
! $output = str_replace("<", "<", $output);
! $output = str_replace(" > ", "><br />", $output);
! $output = str_replace("[ ", "[<br />", $output);
! $output = str_replace("\n", "<br />", $output);
! echo $output."<br />";
! }
! }
! if ($dom->hasChildNodes())
! {
! echoTree($dom->firstChild, $deep);
! }
! echoTree($dom->documentElement);
! echo "</pre>";
! }
! if ($dom->nodeType == DOCUMENT_FRAGMENT_NODE)
! {
! echoTree($dom->firstChild);
! }
! if ($dom->nodeType == ELEMENT_NODE)
! {
! echo $space;
! echo "<span style=\"color:#000099\">";
! echo "<".$dom->tagName;
! if (isset($dom->attributes))
! {
! for ($i = 0; $i < $dom->attributes->getLength(); $i++)
! {
! $elem =& $dom->attributes->item($i);
! echo " ".$elem->getName()."=\"".$elem->getValue()."\"";
! }
! }
!
! if ($dom->hasChildNodes())
! {
! echo "><br />";
! echo "</span>";
! echoTree($dom->firstChild, $deep+4);
! echo $space;
! echo "<span style=\"color:#000099\">";
! echo "</".$dom->tagName."><br />";
! echo "</span>";
! }
! else
! {
! echo " /><br />";
! echo "</span>";
! }
! }
! if ($dom->nodeType == TEXT_NODE)
! {
! echo $space;
! echo htmlspecialchars($dom->getData());
! echo "<br />";
! }
! if ($dom->nodeType == PROCESSING_INSTRUCTION_NODE)
! {
! echo $space;
! echo "<span style=\"color:#990099\">";
! echo "<?".$dom->getTarget()." ";
! $output = htmlspecialchars($dom->getData());
! $output = trim($output);
! $output = str_replace(" ", " ", $output);
! $output = str_replace("\t", " ", $output);
! if (!(strpos($output, "\n")) === false)
! {
! $output = "<br />".$space.$output."<br />".$space;
! $output = str_replace("\n", "<br />".$space, $output);
! echo $output;
! echo "?><br />";
! }
! else
! {
! echo $output;
! echo " ?><br />";
! }
! echo "</span>";
! }
! if (isset($dom->nextSibling))
! {
! echoTree($dom->nextSibling, $deep);
! }
}
$dom = new phpXD("sample.xml");
echoTree($dom->document);
-
?>
--- 14,152 ----
* @author Thomas Dohmke <th...@do...>
* @version $Revision$
*/
require("phpXD.php");
! function echoTree(&$dom, $deep = 0) {
! $space = "";
! for ($i = 0; $i < $deep; $i++) $space .= " ";
! if ($dom->nodeType == CDATA_SECTION_NODE) {
! echo $space;
! echo "<span style=\"color:#990000\">";
! echo "<![CDATA[";
! $output = htmlspecialchars($dom->getData());
! if (!(strpos($output, "\n") === false)) {
! $break = "<br />";
! }
! else {
! $break = "";
! $space = "";
! }
! echo $break.$space;
! $output = str_replace(" ", " ", $output);
! $output = str_replace("\n", "<br />".$space, $output);
! $output = str_replace("\t", " ", $output);
! echo $output;
! echo $break.$space;
! echo "]]><br />";
! echo "</span>";
! }
! if ($dom->nodeType == COMMENT_NODE) {
! echo $space;
! echo "<span style=\"color:#009900\">";
! echo "<!--";
! $output = htmlspecialchars($dom->getData());
! if (!(strpos($output, "\n") === false)) {
! $break = "<br />";
! }
! else {
! $break = "";
! $space = "";
! }
! echo $break.$space;
! $output = str_replace(" ", " ", $output);
! $output = str_replace("\n", "<br />".$space, $output);
! $output = str_replace("\t", " ", $output);
! echo $output;
! echo $break.$space;
! echo "--><br />";
! echo "</span>";
! }
! if ($dom->nodeType == DOCUMENT_NODE) {
! echo "<pre>";
! if (!empty($dom->doctype)) {
! if (!empty($dom->doctype->publicId) && !empty($dom->doctype->systemId)) {
! echo "<!DOCTYPE ".$dom->doctype->name." PUBLIC ".
! $dom->doctype->systemId." ".$dom->doctype->publicId.">\n";
! }
! else {
! if (!empty($dom->doctype->systemId)) {
! echo "<!DOCTYPE ".$dom->doctype->name." SYSTEM ".
! $dom->doctype->systemId.">\n";
! }
! else {
! $output = $dom->doctype->internalSubset;
! $output = str_replace("<", "<", $output);
! $output = str_replace(" > ", "><br />", $output);
! $output = str_replace("[ ", "[<br />", $output);
! $output = str_replace("\n", "<br />", $output);
! echo $output."<br />";
! }
! }
! }
! if ($dom->hasChildNodes()) {
! echoTree($dom->firstChild, $deep);
! }
! echoTree($dom->documentElement);
! echo "</pre>";
! }
! if ($dom->nodeType == DOCUMENT_FRAGMENT_NODE) {
! echoTree($dom->firstChild);
! }
! if ($dom->nodeType == ELEMENT_NODE) {
! echo $space;
! echo "<span style=\"color:#000099\">";
! echo "<".$dom->tagName;
! if (isset($dom->attributes)) {
! for ($i = 0; $i < $dom->attributes->getLength(); $i++) {
! $elem =& $dom->attributes->item($i);
! echo " ".$elem->getName()."=\"".$elem->getValue()."\"";
! }
! }
!
! if ($dom->hasChildNodes()) {
! echo "><br />";
! echo "</span>";
! echoTree($dom->firstChild, $deep+4);
! echo $space;
! echo "<span style=\"color:#000099\">";
! echo "</".$dom->tagName."><br />";
! echo "</span>";
! }
! else {
! echo " /><br />";
! echo "</span>";
! }
! }
! if ($dom->nodeType == TEXT_NODE) {
! echo $space;
! echo htmlspecialchars($dom->getData());
! echo "<br />";
! }
! if ($dom->nodeType == PROCESSING_INSTRUCTION_NODE) {
! echo $space;
! echo "<span style=\"color:#990099\">";
! echo "<?".$dom->getTarget()." ";
! $output = htmlspecialchars($dom->getData());
! $output = trim($output);
! $output = str_replace(" ", " ", $output);
! $output = str_replace("\t", " ", $output);
! if (!(strpos($output, "\n")) === false) {
! $output = "<br />".$space.$output."<br />".$space;
! $output = str_replace("\n", "<br />".$space, $output);
! echo $output;
! echo "?><br />";
! }
! else {
! echo $output;
! echo " ?><br />";
! }
! echo "</span>";
! }
! if (isset($dom->nextSibling)) {
! echoTree($dom->nextSibling, $deep);
! }
}
$dom = new phpXD("sample.xml");
echoTree($dom->document);
?>
|
|
From: Thomas D. <th...@us...> - 2001-11-26 21:27:01
|
Update of /cvsroot/phpxd/phpXD In directory usw-pr-cvs1:/tmp/cvs-serv4609 Modified Files: phpXD.php Log Message: Index: phpXD.php =================================================================== RCS file: /cvsroot/phpxd/phpXD/phpXD.php,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -r1.17 -r1.18 *** phpXD.php 2001/11/25 17:49:36 1.17 --- phpXD.php 2001/11/26 21:26:58 1.18 *************** *** 14,23 **** * XML extension (libexpat) is used. Some interface supports DOM Level 2 yet. * ! * @link http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html ! * @link http://www.w3.org/TR/DOM-Level-2-Core ! * @copyright Copyright (c) 2001 Thomas Dohmke. All rights reserved. ! * @author Thomas Dohmke <th...@do...> ! * @version $Revision$ ! * @access public */ --- 14,22 ---- * XML extension (libexpat) is used. Some interface supports DOM Level 2 yet. * ! * @package phpXD ! * @author Thomas Dohmke <th...@do...> ! * @link http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html ! * @link http://www.w3.org/TR/DOM-Level-2-Core ! * @version $Revision$ */ *************** *** 45,50 **** * The Document node. * ! * @access protected ! * @var Document */ var $document; --- 44,49 ---- * The Document node. * ! * @private ! * @type Document */ var $document; *************** *** 54,59 **** * parsing a XML file! * ! * @access protected ! * @var Node */ var $currentNode; --- 53,58 ---- * parsing a XML file! * ! * @private ! * @type Node */ var $currentNode; *************** *** 62,67 **** * The last node which is parsed. Only valid while parsing a XML file! * ! * @access protected ! * @var Node */ var $lastNode; --- 61,66 ---- * The last node which is parsed. Only valid while parsing a XML file! * ! * @private ! * @type Node */ var $lastNode; *************** *** 71,76 **** * CDataSection node. Only valid while parsing a XML file! * ! * @access protected ! * @var boolean */ var $parseCData; --- 70,75 ---- * CDataSection node. Only valid while parsing a XML file! * ! * @private ! * @type boolean */ var $parseCData; *************** *** 79,84 **** * The parsed DTD string. Only valid while parsing a XML file! * ! * @access protected ! * @var string */ var $parsedDTD; --- 78,83 ---- * The parsed DTD string. Only valid while parsing a XML file! * ! * @private ! * @type string */ var $parsedDTD; *************** *** 88,93 **** * a XML file! * ! * @access protected ! * @var boolean */ var $parsedDTDInternal = false; --- 87,92 ---- * a XML file! * ! * @private ! * @type boolean */ var $parsedDTDInternal = false; *************** *** 96,101 **** * A array with the defined namespaces. * ! * @access protected ! * @var array */ var $namespaces = false; --- 95,100 ---- * A array with the defined namespaces. * ! * @private ! * @type array */ var $namespaces = false; *************** *** 105,110 **** * is loaded. * ! * @access public ! * @var string $file */ function phpXD($file = "") { --- 104,109 ---- * is loaded. * ! * @public ! * @param $file A filename of a XML file. */ function phpXD($file = "") { *************** *** 120,125 **** * Loads the XML file specified by $file and creates the DOM tree. * ! * @access public ! * @var string $file */ function loadFile($file) { --- 119,124 ---- * Loads the XML file specified by $file and creates the DOM tree. * ! * @public ! * @param $file A filename of a XML file. */ function loadFile($file) { *************** *** 145,150 **** if (!xml_parse($parser, $content, true)) { $this->displayError("XML error in file %s, line %d: %s", ! $file, ! xml_get_current_line_number($parser), xml_error_string(xml_get_error_code($parser))); } --- 144,148 ---- if (!xml_parse($parser, $content, true)) { $this->displayError("XML error in file %s, line %d: %s", ! $file, xml_get_current_line_number($parser), xml_error_string(xml_get_error_code($parser))); } *************** *** 163,169 **** * the XML markup are stripped. * ! * @access private ! * @var Node $dom ! * @var boolean $trim */ function saveFile($file, $trim = false) { --- 161,167 ---- * the XML markup are stripped. * ! * @public ! * @param $dom The documentElement of a DOM. ! * @param $trim <code>true</code> or <code>false</code>. */ function saveFile($file, $trim = false) { *************** *** 178,187 **** * Writes the DOM tree recursively to the string $text as XML. * ! * @access private ! * @var Node $dom ! * @var int $deep ! * @var boolean $trim ! * @var string $text ! * @var string $file */ function saveTree(&$dom, $deep, $trim, &$text) { --- 176,185 ---- * Writes the DOM tree recursively to the string $text as XML. * ! * @private ! * @param $dom ! * @param $deep ! * @param $trim ! * @param $text ! * @param $file */ function saveTree(&$dom, $deep, $trim, &$text) { *************** *** 279,283 **** * The Element Start Handler for Expat. * ! * @access private */ function handleStartElement($parser, $name, $attributes) { --- 277,281 ---- * The Element Start Handler for Expat. * ! * @private */ function handleStartElement($parser, $name, $attributes) { *************** *** 375,379 **** * The Element End Handler for Expat. * ! * @access private */ function handleEndElement($parser, $name) { --- 373,377 ---- * The Element End Handler for Expat. * ! * @private */ function handleEndElement($parser, $name) { *************** *** 385,389 **** * The CharacterData Handler for Expat. * ! * @access private */ function handleCharacterData($parser, $text) { --- 383,387 ---- * The CharacterData Handler for Expat. * ! * @private */ function handleCharacterData($parser, $text) { *************** *** 417,421 **** * The ProcessingInstruction Handler for Expat. * ! * @access private */ function handleProcessingInstruction($parser, $target, $data) { --- 415,419 ---- * The ProcessingInstruction Handler for Expat. * ! * @private */ function handleProcessingInstruction($parser, $target, $data) { *************** *** 435,439 **** * is set by handleDefault. * ! * @access private */ function handleDTD($parser, $data) { --- 433,437 ---- * is set by handleDefault. * ! * @private */ function handleDTD($parser, $data) { *************** *** 477,481 **** * The Default Handler for Expat. * ! * @access private */ function handleDefault($parser, $data) { --- 475,479 ---- * The Default Handler for Expat. * ! * @private */ function handleDefault($parser, $data) { *************** *** 516,520 **** * Displays errors, which occur while parsing. * ! * @access private */ function displayError($message) { --- 514,518 ---- * Displays errors, which occur while parsing. * ! * @private */ function displayError($message) { |
|
From: Thomas D. <th...@us...> - 2001-11-26 21:11:40
|
Update of /cvsroot/phpxd/phpXD/include
In directory usw-pr-cvs1:/tmp/cvs-serv31104/include
Modified Files:
attr.php
Log Message:
Index: attr.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/attr.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** attr.php 2001/06/28 15:29:21 1.3
--- attr.php 2001/11/26 21:11:37 1.4
***************
*** 16,203 ****
class Attr extends Node
{
! /**
! * The name of the attribute.
! * DOM-Level 1
! *
! * @access protected
! * @var string
! */
! var $name;
!
! /**
! * A link to the Element object that owns this attribute. If it is unowned,
! * it equals NULL.
! * DOM-Level 2
! *
! * @access protected
! * @var Node
! */
! var $ownerElement;
!
! /**
! * If this attribute was explicity set in the XML source for the parent
! * element or it is a default value in the DTD (currently not supported by
! * phpXD) specified is true.
! * DOM-Level 1
! *
! * @access protected
! * @var boolean
! */
! var $specified;
!
! /**
! * The value of the attribute.
! * DOM-Level 1
! *
! * @access protected
! * @var string
! */
! var $value;
!
! /**
! * Constructor of the class.
! *
! * @access public
! */
! function Attr()
! {
! Node::Node();
! $this->nodeType = ATTRIBUTE_NODE;
! $this->specified = true;
! $this->name =& $this->nodeName;
! }
!
! /**
! * Returns the name of the attribute.
! * DOM-Level 1
! *
! * @access public
! * @return string
! */
! function getName()
! {
! return $this->name;
! }
!
! /**
! * Returns a reference to the owner of the attribute.
! * DOM-Level 2
! *
! * @access public
! * @return Node
! */
! function &getOwnerElement()
! {
! return $this->ownerElement;
! }
!
! /**
! * Returns true if the attribute was set explicity in the XML Source or in
! * the DTD (not supported).
! * DOM-Level 1
! *
! * @access public
! * @return boolean
! */
! function getSpecified()
! {
! return $this->specified;
! }
!
! /**
! * Return the value of the attribute.
! * DOM-Level 1
! *
! * @access public
! * @return string
! */
! function getValue()
! {
! if (isset($this->value))
! {
! return $this->value;
! }
! }
!
! /**
! * Sets the value of the attribute
! * DOM-Level 1
! *
! * @access public
! * @var string $value
! */
! function setValue($value)
! {
! if (isset($this->childNodes))
! {
! $child =& $this->firstChild;
! while (isset($child))
! {
! removeChild($child);
! $child =& $this->firstChild;
! }
! }
!
! $new = new Text();
! $new->nodeValue = $value;
! $new->ownerDocument =& $this->ownerDocument;
!
! $this->firstChild =& $new;
! $this->lastChild =& $this->firstChild;
! $this->nodeValue =& $this->firstChild->nodeValue;
! $this->value =& $this->nodeValue;
! }
!
! /**
! * Sets the value of the attribute (inherited function from Node interface)
! * DOM-Level 1
! *
! * @access public
! * @var string $nodeValue
! */
! function setNodeValue($nodeValue)
! {
! $this->setValue($nodeValue);
! }
!
! /**
! * This inherited function from Node interface is not supported by the Attr
! * interface.
! * DOM-Level 1
! *
! * @access public
! * @return NOT_SUPPORTED_ERR
! */
! function &appendChild(&$newChild)
! {
! return NOT_SUPPORTED_ERR;
! }
!
! /**
! * This inherited function from Node interface is not supported by the Attr
! * interface.
! * DOM-Level 1
! *
! * @access public
! * @return NOT_SUPPORTED_ERR
! */
! function &insertBefore(&$newChild, &$refChild)
! {
! return NOT_SUPPORTED_ERR;
! }
!
! /**
! * This inherited function from Node interface is not supported by the Attr
! * interface.
! * DOM-Level 1
! *
! * @access public
! * @return NOT_SUPPORTED_ERR
! */
! function &replaceChild($newChild, $oldChild)
! {
! return NOT_SUPPORTED_ERR;
! }
}
-
?>
--- 16,189 ----
class Attr extends Node
{
! /**
! * The name of the attribute.
! * DOM-Level 1
! *
! * @private
! * @type string
! */
! var $name;
!
! /**
! * A link to the Element object that owns this attribute. If it is unowned,
! * it equals NULL.
! * DOM-Level 2
! *
! * @private
! * @type Node
! */
! var $ownerElement;
!
! /**
! * If this attribute was explicity set in the XML source for the parent
! * element or it is a default value in the DTD (currently not supported by
! * phpXD) specified is true.
! * DOM-Level 1
! *
! * @private
! * @type boolean
! */
! var $specified;
!
! /**
! * The value of the attribute.
! * DOM-Level 1
! *
! * @private
! * @type string
! */
! var $value;
!
! /**
! * Constructor of the class.
! *
! * @public
! */
! function Attr() {
! Node::Node();
! $this->nodeType = ATTRIBUTE_NODE;
! $this->specified = true;
! $this->name =& $this->nodeName;
! }
!
! /**
! * Returns the name of the attribute.
! * DOM-Level 1
! *
! * @public
! * @return string
! */
! function getName() {
! return $this->name;
! }
!
! /**
! * Returns a reference to the owner of the attribute.
! * DOM-Level 2
! *
! * @public
! * @return Node
! */
! function &getOwnerElement() {
! return $this->ownerElement;
! }
!
! /**
! * Returns true if the attribute was set explicity in the XML Source or in
! * the DTD (not supported).
! * DOM-Level 1
! *
! * @public
! * @return boolean
! */
! function getSpecified() {
! return $this->specified;
! }
!
! /**
! * Return the value of the attribute.
! * DOM-Level 1
! *
! * @public
! * @return string
! */
! function getValue() {
! if (isset($this->value)) {
! return $this->value;
! }
! }
!
! /**
! * Sets the value of the attribute
! * DOM-Level 1
! *
! * @public
! * @param $value A string.
! */
! function setValue($value) {
! if (isset($this->childNodes)) {
! $child =& $this->firstChild;
! while (isset($child)) {
! removeChild($child);
! $child =& $this->firstChild;
! }
! }
!
! $new = new Text();
! $new->nodeValue = $value;
! $new->ownerDocument =& $this->ownerDocument;
!
! $this->firstChild =& $new;
! $this->lastChild =& $this->firstChild;
! $this->nodeValue =& $this->firstChild->nodeValue;
! $this->value =& $this->nodeValue;
! }
!
! /**
! * Sets the value of the attribute (inherited function from Node interface)
! * DOM-Level 1
! *
! * @public
! * @param $nodeValue A String.
! */
! function setNodeValue($nodeValue) {
! $this->setValue($nodeValue);
! }
!
! /**
! * This inherited function from Node interface is not supported by the Attr
! * interface.
! * DOM-Level 1
! *
! * @public
! * @return NOT_SUPPORTED_ERR
! */
! function &appendChild(&$newChild) {
! return NOT_SUPPORTED_ERR;
! }
!
! /**
! * This inherited function from Node interface is not supported by the Attr
! * interface.
! * DOM-Level 1
! *
! * @public
! * @return NOT_SUPPORTED_ERR
! */
! function &insertBefore(&$newChild, &$refChild) {
! return NOT_SUPPORTED_ERR;
! }
!
! /**
! * This inherited function from Node interface is not supported by the Attr
! * interface.
! * DOM-Level 1
! *
! * @public
! * @return NOT_SUPPORTED_ERR
! */
! function &replaceChild($newChild, $oldChild) {
! return NOT_SUPPORTED_ERR;
! }
}
?>
|
|
From: Thomas D. <th...@us...> - 2001-11-25 17:52:22
|
Update of /cvsroot/phpxd/phpXD In directory usw-pr-cvs1:/tmp/cvs-serv7205 Modified Files: README_DE Log Message: Index: README_DE =================================================================== RCS file: /cvsroot/phpxd/phpXD/README_DE,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** README_DE 2001/07/12 22:55:56 1.2 --- README_DE 2001/11/25 17:52:19 1.3 *************** *** 18,22 **** phpXD ist eine Implementierung des XML DOM für PHP4. Es ermöglicht PHP Skripten den Zugriff auf XML Dokumente durch das W3C Document Object ! Model Level 1 (DOM). Die Unterschiede zu den PHP DOM XML Funktionen (die nur dann --- 18,22 ---- phpXD ist eine Implementierung des XML DOM für PHP4. Es ermöglicht PHP Skripten den Zugriff auf XML Dokumente durch das W3C Document Object ! Model Level 2 (DOM). Die Unterschiede zu den PHP DOM XML Funktionen (die nur dann *************** *** 33,37 **** 3. Eigenschaften ! Im Moment unterstützt phpXD fast alle Schnittstellen des DOM Level 1. Nicht unterstützt werden: - Entity --- 33,37 ---- 3. Eigenschaften ! Im Moment unterstützt phpXD fast alle Schnittstellen des DOM Level 2. Nicht unterstützt werden: - Entity |
|
From: Thomas D. <th...@us...> - 2001-11-25 17:49:39
|
Update of /cvsroot/phpxd/phpXD
In directory usw-pr-cvs1:/tmp/cvs-serv6638
Modified Files:
README phpXD.php
Log Message:
Index: README
===================================================================
RCS file: /cvsroot/phpxd/phpXD/README,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** README 2001/07/12 22:55:56 1.3
--- README 2001/11/25 17:49:36 1.4
***************
*** 18,22 ****
phpXD is a XML DOM-Implementation for PHP4 written in PHP. It offers
methods for accessing the nodes of a XML document using the W3C
! Document Object Model Level 1 (DOM).
The differences to the PHP DOM XML functions (only available if
--- 18,22 ----
phpXD is a XML DOM-Implementation for PHP4 written in PHP. It offers
methods for accessing the nodes of a XML document using the W3C
! Document Object Model Level 2 Core (DOM).
The differences to the PHP DOM XML functions (only available if
***************
*** 32,36 ****
3. Features
! Currently phpXD supports nearly all interfaces of DOM Level 1. Not
supported are:
- Entity
--- 32,36 ----
3. Features
! Currently phpXD supports nearly all interfaces of DOM Level 2. Not
supported are:
- Entity
Index: phpXD.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/phpXD.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** phpXD.php 2001/09/12 23:48:39 1.16
--- phpXD.php 2001/11/25 17:49:36 1.17
***************
*** 42,590 ****
class phpXD
{
! /**
! * The Document node.
! *
! * @access protected
! * @var Document
! */
! var $document;
!
[...1019 lines suppressed...]
+ if (func_num_args() > 1) {
+ $arguments = func_get_args();
+
+ $command = "\$message = sprintf(\$message, ";
+
+ for ( $i = 1; $i < sizeof($arguments); $i++ ) {
+ $command .= "\$arguments[".$i."], ";
+ }
+
+ $command = eregi_replace(", $", ");", $command);
+
+ eval($command);
+ }
+
+ echo "<strong>phpXD error:</strong> ".$message;
+ exit;
+ }
+
}
?>
|
|
From: Thomas D. <th...@us...> - 2001-09-12 23:48:42
|
Update of /cvsroot/phpxd/phpXD
In directory usw-pr-cvs1:/tmp/cvs-serv1584
Modified Files:
phpXD.php
Log Message:
Index: phpXD.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/phpXD.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** phpXD.php 2001/07/12 22:55:56 1.15
--- phpXD.php 2001/09/12 23:48:39 1.16
***************
*** 441,445 ****
$text = str_replace(" ", " ", $text);
! if (!empty($text) && ($text != " "))
{
$this->lastNode =& $this->currentNode->appendChild($this->document->createTextNode($text));
--- 441,445 ----
$text = str_replace(" ", " ", $text);
! if ((strlen($text) > 0) && ($text != " "))
{
$this->lastNode =& $this->currentNode->appendChild($this->document->createTextNode($text));
|
|
From: Thomas D. <th...@us...> - 2001-07-12 22:55:59
|
Update of /cvsroot/phpxd/phpXD
In directory usw-pr-cvs1:/tmp/cvs-serv23949
Modified Files:
README README_DE phpXD.php
Log Message:
Index: README
===================================================================
RCS file: /cvsroot/phpxd/phpXD/README,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** README 2001/06/25 21:40:00 1.2
--- README 2001/07/12 22:55:56 1.3
***************
*** 69,91 ****
"=" could destroy the hierarchy of the tree.
- Don't try to access the DOM through the attributes of the DOM
- interfaces, because if you change for example the data of an
- CharacterData node, the nodeValue of the correnspondent Node is not changed:
- echo $sample->getData(); // e.g.: "hello"
- $sample->data = "new";
- echo $sample->data; // "new"
- echo $sample->nodeValue; // "hello";
-
- Instead of this, use the defined functions to access the DOM, e.g.:
- $root->setData("new");
-
- If you want only to read the attributes, it is allowed, because of this:
- echo $dom->getDocType()->getPublicId(); // doesn't work
-
- $doctype = $dom->getDocType(); // bad style
- echo $doctype->getPublicId();
-
- echo $dom->doctype->publicId; // better
-
For more informations about the DOM interfaces see:
http://www.w3.org/DOM/
--- 69,72 ----
Index: README_DE
===================================================================
RCS file: /cvsroot/phpxd/phpXD/README_DE,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** README_DE 2001/06/25 21:39:13 1.1
--- README_DE 2001/07/12 22:55:56 1.2
***************
*** 75,102 ****
einziges "=" die gesamte Hierachie des DOM zerstören.
- Der Zugriff auf das DOM sollte nicht durch die Eigenschaften
- (Attribute) der DOM Klassen zugegriffen werden, da diese unter
- Umständen zusammenhängen, zum Beispiel wenn man die data Eigenschaft eines
- CharacterData Elements ändert, wird nicht die nodeValue der
- zugehörigen Node geändert:
- echo $sample->getData(); // e.g.: "hello"
- $sample->data = "new";
- echo $sample->data; // "new"
- echo $sample->nodeValue; // "hello";
-
- Stattdessen sollte man die Funktionen des DOM zum Verändern der
- Eigenschaften benutzen, also:
- $root->setData("new");
-
- Will man nur lesend auf die Eigenschaften zugreifen, so ist der
- direkte Zugriff unter Umständen schöner, da in PHP folgendes nicht
- funktioniert:
- echo $dom->getDocType()->getPublicId(); // geht nicht
-
- $doctype = $dom->getDocType(); // unschön
- echo $doctype->getPublicId();
-
- echo $dom->doctype->publicId; // so ist gut
-
Mehr Infos über das DOM und seine Klassen und Funktionen:
http://www.w3.org/DOM/
--- 75,78 ----
Index: phpXD.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/phpXD.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** phpXD.php 2001/07/11 21:35:25 1.14
--- phpXD.php 2001/07/12 22:55:56 1.15
***************
*** 22,25 ****
--- 22,26 ----
*/
+ require("include/node.php");
require("include/attr.php");
require("include/characterdata.php");
***************
*** 34,38 ****
require("include/entityreference.php");
require("include/namednodemap.php");
- require("include/node.php");
require("include/nodelist.php");
require("include/processinginstruction.php");
--- 35,38 ----
***************
*** 134,139 ****
{
$this->document = new Document();
- $this->document->nodeName = "#document";
- $this->document->nodeType = DOCUMENT_NODE;
$parser = xml_parser_create();
--- 134,137 ----
|
|
From: Thomas D. <th...@us...> - 2001-07-11 21:53:40
|
Update of /cvsroot/phpxd/phpXD
In directory usw-pr-cvs1:/tmp/cvs-serv9428
Modified Files:
sample.php sample.xml
Log Message:
Index: sample.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/sample.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** sample.php 2001/07/11 21:35:25 1.2
--- sample.php 2001/07/11 21:53:37 1.3
***************
*** 171,178 ****
$dom = new phpXD("sample.xml");
- $dom->document->documentElement->appendChild($dom->document->createTextNode("a"));
- $dom->document->documentElement->appendChild($dom->document->createTextNode(" "));
- $dom->document->documentElement->appendChild($dom->document->createTextNode("b"));
- $dom->document->documentElement->normalize();
echoTree($dom->document);
--- 171,174 ----
Index: sample.xml
===================================================================
RCS file: /cvsroot/phpxd/phpXD/sample.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** sample.xml 2001/07/11 21:35:25 1.2
--- sample.xml 2001/07/11 21:53:37 1.3
***************
*** 1,9 ****
<?xml version="1.0"?>
! <dc:hello xmlns:dc="http://www.w3.org/XML/1998/namespace">
This is a phpXD sample dokument.
Here are some sample XML features.
! <dc:a_child>
Hello World.
! </dc:a_child>
<an_empty_child />
<!-- This is a comment... -->
--- 1,9 ----
<?xml version="1.0"?>
! <hello>
This is a phpXD sample dokument.
Here are some sample XML features.
! <a_child>
Hello World.
! </a_child>
<an_empty_child />
<!-- This is a comment... -->
***************
*** 13,15 ****
echo "PHP is cool";
?>
! </dc:hello>
--- 13,15 ----
echo "PHP is cool";
?>
! </hello>
|
|
From: Thomas D. <th...@us...> - 2001-07-11 21:35:28
|
Update of /cvsroot/phpxd/phpXD
In directory usw-pr-cvs1:/tmp/cvs-serv5317
Modified Files:
phpXD.php sample.php sample.xml
Log Message:
Fixed bug in saveFile.
Index: phpXD.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/phpXD.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** phpXD.php 2001/06/28 22:22:49 1.13
--- phpXD.php 2001/07/11 21:35:25 1.14
***************
*** 176,180 ****
$fp = fopen($file, "w");
fwrite($fp, "<?xml version=\"1.0\"?>\n"); // <?
! $this->saveTree($this->document, 0, true, &$text);
fwrite($fp, $text);
fclose($fp);
--- 176,180 ----
$fp = fopen($file, "w");
fwrite($fp, "<?xml version=\"1.0\"?>\n"); // <?
! $this->saveTree($this->document, 0, $trim, &$text);
fwrite($fp, $text);
fclose($fp);
Index: sample.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/sample.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** sample.php 2001/06/21 18:59:36 1.1.1.1
--- sample.php 2001/07/11 21:35:25 1.2
***************
*** 171,174 ****
--- 171,178 ----
$dom = new phpXD("sample.xml");
+ $dom->document->documentElement->appendChild($dom->document->createTextNode("a"));
+ $dom->document->documentElement->appendChild($dom->document->createTextNode(" "));
+ $dom->document->documentElement->appendChild($dom->document->createTextNode("b"));
+ $dom->document->documentElement->normalize();
echoTree($dom->document);
Index: sample.xml
===================================================================
RCS file: /cvsroot/phpxd/phpXD/sample.xml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** sample.xml 2001/06/21 18:59:36 1.1.1.1
--- sample.xml 2001/07/11 21:35:25 1.2
***************
*** 1,9 ****
<?xml version="1.0"?>
! <hello>
This is a phpXD sample dokument.
Here are some sample XML features.
! <a_child>
Hello World.
! </a_child>
<an_empty_child />
<!-- This is a comment... -->
--- 1,9 ----
<?xml version="1.0"?>
! <dc:hello xmlns:dc="http://www.w3.org/XML/1998/namespace">
This is a phpXD sample dokument.
Here are some sample XML features.
! <dc:a_child>
Hello World.
! </dc:a_child>
<an_empty_child />
<!-- This is a comment... -->
***************
*** 13,15 ****
echo "PHP is cool";
?>
! </hello>
--- 13,15 ----
echo "PHP is cool";
?>
! </dc:hello>
|
|
From: Thomas D. <th...@us...> - 2001-07-09 19:04:19
|
Update of /cvsroot/phpxd/phpXD/include
In directory usw-pr-cvs1:/tmp/cvs-serv2798
Modified Files:
element.php
Log Message:
Fixed Bug in getElementsByTagName.
Index: element.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/element.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** element.php 2001/06/28 22:24:23 1.2
--- element.php 2001/07/09 19:04:16 1.3
***************
*** 91,95 ****
{
$result = new NodeList();
! $this->getElementsByTagNameList($tagName, $this->firstChild, $result);
return $result;
}
--- 91,95 ----
{
$result = new NodeList();
! $this->getElementsByTagNameList($name, $this->firstChild, $result);
return $result;
}
|
|
From: Thomas D. <th...@us...> - 2001-06-28 22:28:16
|
Update of /cvsroot/phpxd/phpXD In directory usw-pr-cvs1:/tmp/cvs-serv1523 Modified Files: DEVELOPMENT Log Message: Update project status. Index: DEVELOPMENT =================================================================== RCS file: /cvsroot/phpxd/phpXD/DEVELOPMENT,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** DEVELOPMENT 2001/06/28 22:26:41 1.4 --- DEVELOPMENT 2001/06/28 22:28:13 1.5 *************** *** 30,33 **** With "*" marked interfaces are not implemented yet. With "**" marked interfaces are partly implemented, but some ! attributes/functions my miss because of the lack of parsing DTDs. With "na" marked interfaces haven't new DOM Level 2 properties/methods. --- 30,33 ---- With "*" marked interfaces are not implemented yet. With "**" marked interfaces are partly implemented, but some ! attributes/functions may miss because of the lack of parsing DTDs. With "na" marked interfaces haven't new DOM Level 2 properties/methods. |
|
From: Thomas D. <th...@us...> - 2001-06-28 22:26:44
|
Update of /cvsroot/phpxd/phpXD In directory usw-pr-cvs1:/tmp/cvs-serv404 Modified Files: DEVELOPMENT Log Message: Update project status. Index: DEVELOPMENT =================================================================== RCS file: /cvsroot/phpxd/phpXD/DEVELOPMENT,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** DEVELOPMENT 2001/06/28 22:22:49 1.3 --- DEVELOPMENT 2001/06/28 22:26:41 1.4 *************** *** 20,25 **** DOMImplementation yes yes Element yes yes ! Entity ** na ! EntityReference ** na NamedNodeMap yes yes Node yes yes --- 20,25 ---- DOMImplementation yes yes Element yes yes ! Entity * na ! EntityReference * na NamedNodeMap yes yes Node yes yes |
|
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 */
}
}
|
|
From: Thomas D. <th...@us...> - 2001-06-28 22:22:52
|
Update of /cvsroot/phpxd/phpXD
In directory usw-pr-cvs1:/tmp/cvs-serv31889
Modified Files:
phpXD.php DEVELOPMENT
Log Message:
Attributes/Function for DOM Level 2 added.
Some Bugs fixed.
Index: phpXD.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/phpXD.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** phpXD.php 2001/06/21 21:37:52 1.12
--- phpXD.php 2001/06/28 22:22:49 1.13
***************
*** 94,97 ****
--- 94,105 ----
/**
+ * A array with the defined namespaces.
+ *
+ * @access protected
+ * @var array
+ */
+ var $namespaces = false;
+
+ /**
* The Constructor of the class. If $file is set, the XML file
* is loaded.
***************
*** 102,105 ****
--- 110,116 ----
function phpXD($file = "")
{
+ $this->namespaces["xml"] = "http://www.w3.org/XML/1998/namespace";
+ $this->namespaces["xmlns"] = "http://www.w3.org/2000/xmlns/";
+
if (!empty($file))
{
***************
*** 295,319 ****
function handleStartElement($parser, $name, $attributes)
{
if (!isset($this->document->documentElement))
{
! $this->document->documentElement =& $this->document->createElement($name);
$this->currentNode =& $this->document->documentElement;
}
else
{
- $newChild = $this->document->createElement($name);
$this->currentNode->appendChild($newChild);
$this->currentNode =& $newChild;
}
if (is_array($attributes))
{
while (list($name, $value) = each($attributes))
{
! $this->currentNode->setAttribute($name, $value);
! $attr =& $this->currentNode->getAttributeNode($name);
! $attr->specified = true;
}
}
$this->lastNode =& $this->currentNode;
}
--- 306,407 ----
function handleStartElement($parser, $name, $attributes)
{
+ if (!(strpos($name, ":") === false))
+ {
+ $prefix = substr($name, 0, strpos($name, ":"));
+ if (is_array($attributes) &&
+ !empty($attributes["xmlns:".$prefix]))
+ {
+ $namespace = $attributes["xmlns:".$prefix];
+ }
+ else
+ if (is_array($this->namespaces) &&
+ !empty($this->namespaces[$prefix]))
+ {
+ $namespace = $this->namespaces[$prefix];
+ }
+ else
+ {
+ $this->displayError("XML error: unknown namespace in line %d.", xml_get_current_line_number($parser));
+ }
+
+ $this->namespaces[$prefix] = $namespace;
+ }
+
+ if (!(strpos($name, ":") === false))
+ {
+ $newChild =& $this->document->createElementNS($namespace, $name);
+ }
+ else
+ {
+ $newChild =& $this->document->createElement($name);
+ }
+
+ if ($newChild == NAME_SPACE_ERR)
+ {
+ $this->displayError("XML error: namespace not valid in line %d.", xml_get_current_line_number($parser));
+ }
+
if (!isset($this->document->documentElement))
{
! $this->document->documentElement =& $newChild;
$this->currentNode =& $this->document->documentElement;
}
else
{
$this->currentNode->appendChild($newChild);
$this->currentNode =& $newChild;
}
+
if (is_array($attributes))
{
while (list($name, $value) = each($attributes))
{
! if (!(strpos($name, ":") === false))
! {
! $prefix = substr($name, 0, strpos($name, ":"));
! $localName = substr($name, strpos($this->nodeName, ":")+1);
! if ($prefix == "xmlns")
! {
! $this->namespaces[$localName] = $value;
! $namespace = $this->namespaces["xmlns"];
! }
! else
! {
! if (is_array($attributes) &&
! !empty($attributes["xmlns:".$prefix]))
! {
! $namespace = $attributes["xmlns:".$prefix];
! }
! else
! if (is_array($this->namespaces) &&
! !empty($this->namespaces[$prefix]))
! {
! $namespace = $this->namespaces[$prefix];
! }
! else
! {
! $this->displayError("XML error: unknown namespace in line %d.", xml_get_current_line_number($parser));
! }
! }
+ $result = $this->currentNode->setAttributeNS($namespace, $name, $value);
+
+ if ($result == NAME_SPACE_ERR)
+ {
+ $this->displayError("XML error: namespace not valid in line %d.", xml_get_current_line_number($parser));
+ }
+
+ $attr =& $this->currentNode->getAttributeNode($name);
+ $attr->specified = true;
+ }
+ else
+ {
+ $this->currentNode->setAttribute($name, $value);
+ $attr =& $this->currentNode->getAttributeNode($name);
+ $attr->specified = true;
+ }
}
}
+
$this->lastNode =& $this->currentNode;
}
***************
*** 350,355 ****
else
{
! $text = trim($text);
! if (!empty($text))
{
$this->lastNode =& $this->currentNode->appendChild($this->document->createTextNode($text));
--- 438,447 ----
else
{
! $text = str_replace("\t", "", $text);
! $text = str_replace("\n", " ", $text);
! $text = str_replace("\r", "", $text);
! $text = str_replace(" ", " ", $text);
!
! if (!empty($text) && ($text != " "))
{
$this->lastNode =& $this->currentNode->appendChild($this->document->createTextNode($text));
Index: DEVELOPMENT
===================================================================
RCS file: /cvsroot/phpxd/phpXD/DEVELOPMENT,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** DEVELOPMENT 2001/06/21 19:15:29 1.2
--- DEVELOPMENT 2001/06/28 22:22:49 1.3
***************
*** 14,27 ****
CharaceterData yes na
Comment yes na
! Document yes *
DocumentFragment yes na
! DocumentType * yes
DOMException yes yes
! DOMImplementation yes *
! Element yes *
! Entity * na
! EntityReference * na
! NamedNodeMap yes *
! Node yes *
NodeList yes na
ProcessingInstruction yes na
--- 14,27 ----
CharaceterData yes na
Comment yes na
! Document yes **
DocumentFragment yes na
! DocumentType ** yes
DOMException yes yes
! DOMImplementation yes yes
! Element yes yes
! Entity ** na
! EntityReference ** na
! NamedNodeMap yes yes
! Node yes yes
NodeList yes na
ProcessingInstruction yes na
***************
*** 29,31 ****
With "*" marked interfaces are not implemented yet.
! With "na" marked interfaces haven't new DOM Level 2 properties/methods.
--- 29,33 ----
With "*" marked interfaces are not implemented yet.
! With "**" marked interfaces are partly implemented, but some
! attributes/functions my miss because of the lack of parsing DTDs.
! With "na" marked interfaces haven't new DOM Level 2 properties/methods.
\ No newline at end of file
|
|
From: Thomas D. <th...@us...> - 2001-06-28 17:18:51
|
Update of /cvsroot/phpxd/phpXD/include
In directory usw-pr-cvs1:/tmp/cvs-serv24239/include
Modified Files:
node.php
Log Message:
DOM Level 2 added.
Index: node.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/node.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** node.php 2001/06/21 18:59:44 1.1.1.1
--- node.php 2001/06/28 17:18:48 1.2
***************
*** 190,194 ****
/**
* Contains the local part of the fully qualified node name.
! * DOM-Level 2 -- NYI
*
* @access protected
--- 190,194 ----
/**
* Contains the local part of the fully qualified node name.
! * DOM-Level 2
*
* @access protected
***************
*** 200,204 ****
* The namespace URI given to this Node object at creation time, null
* if no namespace was given.
! * DOM-Level 2 -- NYI
*
* @access protected
--- 200,204 ----
* The namespace URI given to this Node object at creation time, null
* if no namespace was given.
! * DOM-Level 2
*
* @access protected
***************
*** 210,214 ****
* The namespace prefix of this Node, used for nodes that support namespace
* prefixes.
! * DOM-Level 2 -- NYI
*
* @access protected
--- 210,214 ----
* The namespace prefix of this Node, used for nodes that support namespace
* prefixes.
! * DOM-Level 2
*
* @access protected
***************
*** 526,533 ****
return true;
}
! else
! {
! return false;
! }
}
--- 526,530 ----
return true;
}
! return false;
}
***************
*** 734,738 ****
/**
* Returns the local part of the fully qualified node name.
! * DOM-Level 2 -- NYI
*
* @access public
--- 731,735 ----
/**
* Returns the local part of the fully qualified node name.
! * DOM-Level 2
*
* @access public
***************
*** 741,750 ****
function getLocalName()
{
! return NOT_SUPPORTED_ERR;
}
/**
* Returns the namespace URI of this node.
! * DOM-Level 2 -- NYI
*
* @access public
--- 738,747 ----
function getLocalName()
{
! return $this->localName;
}
/**
* Returns the namespace URI of this node.
! * DOM-Level 2
*
* @access public
***************
*** 753,762 ****
function getNamespaceURI()
{
! return NOT_SUPPORTED_ERR;
}
/**
* Returns the namespace prefix of this node.
! * DOM-Level 2 -- NYI
*
* @access public
--- 750,759 ----
function getNamespaceURI()
{
! return $this->namespaceURI;
}
/**
* Returns the namespace prefix of this node.
! * DOM-Level 2
*
* @access public
***************
*** 765,769 ****
function getPrefix()
{
! return NOT_SUPPORTED_ERR;
}
--- 762,766 ----
function getPrefix()
{
! return $this->prefix;
}
***************
*** 772,776 ****
* type nodes, changing the namespace prefix also affects the nodeName,
* tagName and name attributes.
! * DOM-Level 2 -- NYI
*
* @access public
--- 769,773 ----
* type nodes, changing the namespace prefix also affects the nodeName,
* tagName and name attributes.
! * DOM-Level 2
*
* @access public
***************
*** 780,789 ****
function setPrefix($prefix)
{
! return NOT_SUPPORTED_ERR;
}
/**
* Indicates whether an Element node has any attributes.
! * DOM-Level 2 -- NYI
*
* @access public
--- 777,802 ----
function setPrefix($prefix)
{
! if (empty($this->namespaceURI))
! return NAMESPACE_ERR;
!
! if ($this->namespaceURI != "http://www.w3.org/XML/1998/namespace" && $prefix == "xml")
! return NAMESPACE_ERR;
!
! if ($this->nodeType == ATTRIBUTE_NODE)
! {
! if ($this->namespaceURI != "http://www.w3.org/2000/xmlns/" && $prefix == "xmlns")
! return NAMESPACE_ERR;
!
! if ($this->qualifiedName == "xmlns")
! return NAMESPACE_ERR;
! }
!
! $this->prefix = $prefix;
! $this->nodeName = $prefix.substr($this->nodeName, 0, strpos($this->nodeName, ":"));
}
/**
* Indicates whether an Element node has any attributes.
! * DOM-Level 2
*
* @access public
***************
*** 792,796 ****
function hasAttributes()
{
! return NOT_SUPPORTED_ERR;
}
--- 805,813 ----
function hasAttributes()
{
! if (isset($this->attributes) && $this->attributes->getLength() > 0)
! {
! return true;
! }
! return false;
}
***************
*** 798,802 ****
* Checks to see if a particular DOM feature is available for this
* implementation.
! * DOM-Level 2 -- NYI
*
* @access public
--- 815,819 ----
* Checks to see if a particular DOM feature is available for this
* implementation.
! * DOM-Level 2
*
* @access public
***************
*** 805,811 ****
* @return boolean
*/
! function isSupported($feature, $version)
{
! return NOT_SUPPORTED_ERR;
}
--- 822,835 ----
* @return boolean
*/
! function isSupported($feature, $version = "1.0")
{
! if (($feature == "XML") || ($feature == "Core"))
! {
! if (($version == "1.0") || ($version == "2.0"))
! {
! return true;
! }
! }
! return false;
}
***************
*** 813,817 ****
* Recursively combines all adjacent Text nodes into a single node. It
* also removes empty Text nodes from the document tree.
! * DOM-Level 2 -- NYI
*
* @access public
--- 837,841 ----
* Recursively combines all adjacent Text nodes into a single node. It
* also removes empty Text nodes from the document tree.
! * DOM-Level 2
*
* @access public
***************
*** 820,824 ****
function normalize()
{
! return NOT_SUPPORTED_ERR;
}
--- 844,895 ----
function normalize()
{
! if ($this->nodeType == "ELEMENT_NODE" && $this->hasAttribues())
! {
! for ($i = 0; $i < $this->attributes->getLength(); $i++)
! {
! $attr =& $this->attributes->item($i);
! $attr->normalize();
! }
! }
!
!
! if ($this->hasChildNodes())
! {
! $child =& $this->firstChild;
! $prevChild = NULL;
! while (isset($child))
! {
! if ($child->hasChildNodes())
! {
! $child->normalize();
! }
!
! if (($child->nodeType == TEXT_NODE) and
! (isset($prevChild)) and
! ($prevChild->nodeType == TEXT_NODE))
! {
! if ($prevChild->getLength() > 0)
! {
! $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;
! }
! }
}
|
|
From: Thomas D. <th...@us...> - 2001-06-28 15:29:25
|
Update of /cvsroot/phpxd/phpXD/include
In directory usw-pr-cvs1:/tmp/cvs-serv21001/include
Modified Files:
attr.php
Log Message:
Debugging output in setValue removed.
Index: attr.php
===================================================================
RCS file: /cvsroot/phpxd/phpXD/include/attr.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** attr.php 2001/06/24 21:12:33 1.2
--- attr.php 2001/06/28 15:29:21 1.3
***************
*** 134,138 ****
while (isset($child))
{
! echo removeChild($child);
$child =& $this->firstChild;
}
--- 134,138 ----
while (isset($child))
{
! removeChild($child);
$child =& $this->firstChild;
}
|