[Phpxd-commits] CVS: phpXD phpXD.php,1.18,1.19
Status: Beta
Brought to you by:
growbal
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) { |