/**
  * Parses XML Layout files used to configure and render views
  *
  * @param DOMElement $ele
  * @param boolean $updateContainer 
  * @return void
  */
 private function parse(DOMElement $ele, $updateContainer)
 {
     $this->eleStack = array($ele);
     if (empty($this->eleList)) {
         $this->eleList = array('root' => $this->root);
     }
     for ($i = 0; count($this->eleStack) > 0; $i++) {
         $cont = TRUE;
         $node = array_shift($this->eleStack);
         if ($pKey = $node->getAttribute('key')) {
             if (!array_key_exists($pKey, $this->eleList)) {
                 $cont = FALSE;
             }
         } else {
             $pKey = 'root';
         }
         if ($cont) {
             $parent = $this->eleList[$pKey];
             if ($node->hasChildNodes()) {
                 $nList = $node->childNodes;
                 $tempQ = array();
                 foreach ($nList as $n) {
                     if ($n->nodeName == Uni_Core_LayoutManager::VIEW) {
                         $cpNode = Uni_Data_XDOMDocument::createNodeIn($n, $this);
                         $parent->appendChild($cpNode);
                         if ($key = $cpNode->getAttribute('key')) {
                             if (array_key_exists($key, $this->eleList)) {
                                 throw new Exception('Duplicte key was found:"' . $key . '"');
                             }
                             $tempQ[$key] = $n;
                             $this->eleList[$key] = $cpNode;
                         }
                     } else {
                         if ($updateContainer && $n->nodeName == Uni_Core_LayoutManager::CONTAINER) {
                             if ($n->hasAttributes()) {
                                 $nKey = $n->attributes->getNamedItem('key');
                                 if ($nKey) {
                                     $this->setContainer($this->defContainer[$nKey->nodeValue]);
                                 }
                             }
                         } else {
                             if ($n->nodeName == Uni_Core_LayoutManager::HEAD) {
                                 $this->parseHead($n);
                             } else {
                                 if ($n->nodeName == self::REF && ($key = $n->getAttribute('key'))) {
                                     $tempQ[] = $n;
                                 } else {
                                     if ($n->nodeName == self::REMOVE && ($key = $n->getAttribute('key'))) {
                                         if (array_key_exists($key, $this->eleList)) {
                                             try {
                                                 $parent->removeChild($this->eleList[$key]);
                                                 unset($this->eleList[$key]);
                                                 if (array_key_exists($key, $tempQ)) {
                                                     unset($tempQ[$key]);
                                                 }
                                             } catch (Exception $e) {
                                             }
                                         } else {
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $this->eleStack = array_merge($this->eleStack, array_values($tempQ));
             }
         }
     }
 }