Пример #1
0
 /**
  * Parser::_prepare()
  * 
  * @access  private
  */
 function _prepare(&$parent)
 {
     if (!Node::isInherited($parent)) {
         return $this->raiseError('the first argument must be object inherited from Node', E_USER_ERROR, 4);
     }
     $this->_parent =& $parent;
     if (Element::isInherited($parent)) {
         $this->_dom =& $parent->ownerDocument;
     } else {
         $this->_dom =& $parent;
     }
 }
 /**
  * Processing php-code in processing-instruction.
  * 
  * @access  private
  */
 function _handlePHPPI($data)
 {
     $_PI_RESULT = null;
     $keys = array_keys($GLOBALS);
     foreach ($keys as $key) {
         ${$key} =& $GLOBALS[$key];
     }
     $eval_result = eval($data . ';');
     if ($_PI_RESULT !== null) {
         $result =& $_PI_RESULT;
     } else {
         $result = $eval_result;
     }
     if ($result === false) {
         $errmsg = sprintf('processing-instruction error on line: %s, column: %s', xml_get_current_line_number($this->_parser), xml_get_current_column_number($this->_parser));
         return $this->raiseError($errmsg);
     } elseif (is_string($result)) {
         $this->_characterDataHandler($this->_parser, $result);
     } elseif (Node::isInherited($result)) {
         $child =& $this->_dom->importNode(&$result, true);
         $this->_parent->appendChild(&$child);
     }
 }
 /**
  * Sets selecting context.
  * 
  * Sets initial context of selecting. But, if you use absolute location
  * path, then method evaluate() selects from root of document.
  * 
  * @param   array       list of objects inherited from Node.
  * @param   boolean     for internal use.
  * @access  public
  */
 function setContext($context, $markup = false)
 {
     if (!is_array($context)) {
         return $this->raiseError('the first argument must be array');
     }
     foreach ($context as $node) {
         if (!Node::isInherited($node)) {
             return $this->raiseError('the context must contain objects Node');
         }
         if ($this->_dom->_ID != $node->ownerDocument->_ID) {
             return $this->raiseError('node is used in a different document
                 than the one that created it');
         }
     }
     $this->_context = $context;
     $this->_markup = (bool) $markup;
     if ($this->_markup) {
         $length = sizeof($this->_context);
         for ($n = 0; $n < $length; $n++) {
             $this->_context[$n]->_context = $this->_context[$n]->_context ? $this->_context[$n]->_context : $this->_context[$n]->_ID;
         }
     }
 }
Пример #4
0
 /**
  * Node::_appendChild()
  * 
  * @access  private
  */
 function &_appendChild(&$newChild)
 {
     if (!Node::isInherited($newChild)) {
         return $this->raiseError('the first argument must be inherited from Node');
     }
     if ($this->ownerDocument->_ID != $newChild->ownerDocument->_ID) {
         return $this->raiseError(WRONG_DOCUMENT_ERR);
     }
     if ($newChild->nodeType < 1 || $newChild->nodeType > 12) {
         return $this->raiseError(NOT_SUPPORTED_ERR);
     }
     if ($newChild->parentNode !== null) {
         $newChild->parentNode->removeChild(&$newChild);
     }
     if (!$this->firstChild) {
         $this->firstChild =& $newChild;
     }
     $newChild->parentNode =& $this;
     $newChild->previousSibling =& $this->lastChild;
     $newChild->nextSibling = null;
     if ($this->lastChild) {
         $this->lastChild->nextSibling =& $newChild;
     }
     $this->lastChild =& $newChild;
     $this->childNodes->addItem(&$newChild);
     return $newChild;
 }