/** * An utility method that cleans the contents of the section node, by * moving the alternative section (opt:sectionelse etc. tags) code to the end * of the children list. * * In the parameters, we must specify the name and the namespace of the * tags that will be treated as the alternative content tags. * * @param Opt_Xml_Element $node The section node * @param String $ns The namespace * @param String $name The alternative section content tag name */ protected function _sortSectionContents(Opt_Xml_Element $node, $ns, $name) { $else = $node->getElementsByTagNameNS($ns, $name, false); if (sizeof($else) == 1) { if (!$node->hasAttributes()) { throw new Opt_InstructionTooManyItems_Exception($ns . ':' . $name, $node->getXmlName(), 'Zero'); } $node->bringToEnd($else[0]); } elseif (sizeof($else) > 1) { throw new Opt_InstructionTooManyItems_Exception($ns . ':' . $name, $node->getXmlName(), 'Zero or one'); } }