| Conditions | 4 |
| Paths | 6 |
| Total Lines | 28 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | protected function normalizeElement(DOMElement $element) |
||
| 32 | { |
||
| 33 | $elName = $element->getAttribute('name'); |
||
| 34 | $dom = $this->ownerDocument; |
||
| 35 | |||
| 36 | try |
||
| 37 | { |
||
| 38 | // Create the new static element |
||
| 39 | $newElement = ($element->hasAttribute('namespace')) |
||
| 40 | ? $dom->createElementNS($element->getAttribute('namespace'), $elName) |
||
| 41 | : $dom->createElement($elName); |
||
| 42 | } |
||
| 43 | catch (DOMException $e) |
||
| 44 | { |
||
| 45 | // Ignore this element if an exception got thrown |
||
| 46 | return; |
||
| 47 | } |
||
| 48 | |||
| 49 | // Replace the old <xsl:element/> with it. We do it now so that libxml doesn't have to |
||
| 50 | // redeclare the XSL namespace |
||
| 51 | $element->parentNode->replaceChild($newElement, $element); |
||
| 52 | |||
| 53 | // One by one and in order, we move the nodes from the old element to the new one |
||
| 54 | while ($element->firstChild) |
||
| 55 | { |
||
| 56 | $newElement->appendChild($element->removeChild($element->firstChild)); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } |