branched = false; } public function execute () { $current = $this->node; // Seek other else-if or else elements for a suitable branch do { $next = $current->nextSibling; if (!$this->branched) { if ($current->localName === 'else') { $this->branch($current); } elseif ($current->childNodes->length > 0) { // @TODO improve this $this->getVariable_cascade($current->getAttribute('variable')) and $this->branch($current); } } $current->parentNode->removeChild($current); // Remove the current node $current = $next; } while($current instanceof DOMNode && $current->namespaceURI === XIRL_NAMESPACE && ($current->localName === 'else-if' || $current->localName === 'else')); } public function branch (DOMNode $branch) { // Proccess the child nodes $process = $this->template->createProcess(); foreach ($branch->childNodes as $node) { $process->enqueue($node); } // Process the nodes $process->process(); while ($branch->hasChildNodes()) { $branch->parentNode->insertBefore($branch->firstChild, $branch); } $this->branched = true; } } ?>