@@ -44,24 +44,20 @@ discard block |
||
| 44 | 44 | $class = get_class($xml); |
| 45 | 45 | if ($class == 'DOMElement') { |
| 46 | 46 | $this->appendChild($this->importNode($xml, true)); |
| 47 | - } |
|
| 48 | - else if ($class == 'DOMDocument') { |
|
| 47 | + } else if ($class == 'DOMDocument') { |
|
| 49 | 48 | if ($xml->documentElement) { |
| 50 | 49 | $this->appendChild($this->importNode($xml->documentElement, true)); |
| 51 | 50 | } |
| 52 | - } |
|
| 53 | - else if ($class == 'BetterDOMDocument\DOMDoc') { |
|
| 51 | + } else if ($class == 'BetterDOMDocument\DOMDoc') { |
|
| 54 | 52 | if ($xml->documentElement) { |
| 55 | 53 | $this->appendChild($this->importNode($xml->documentElement, true)); |
| 56 | 54 | } |
| 57 | 55 | $this->ns = $xml->ns; |
| 58 | 56 | } |
| 59 | - } |
|
| 60 | - else if (is_string($xml) && !empty($xml)) { |
|
| 57 | + } else if (is_string($xml) && !empty($xml)) { |
|
| 61 | 58 | if ($this->error_checking == 'none') { |
| 62 | 59 | @$this->loadXML($xml, LIBXML_COMPACT); |
| 63 | - } |
|
| 64 | - else if (!$this->loadXML($xml, LIBXML_COMPACT)) { |
|
| 60 | + } else if (!$this->loadXML($xml, LIBXML_COMPACT)) { |
|
| 65 | 61 | trigger_error('BetterDOMDocument\DOMDoc: Could not load: ' . htmlspecialchars($xml), E_USER_WARNING); |
| 66 | 62 | } |
| 67 | 63 | } |
@@ -116,8 +112,7 @@ discard block |
||
| 116 | 112 | public function lookupURL($prefix) { |
| 117 | 113 | if (isset($this->ns[$prefix])) { |
| 118 | 114 | return $this->ns[$prefix]; |
| 119 | - } |
|
| 120 | - else { |
|
| 115 | + } else { |
|
| 121 | 116 | return FALSE; |
| 122 | 117 | } |
| 123 | 118 | } |
@@ -151,15 +146,13 @@ discard block |
||
| 151 | 146 | |
| 152 | 147 | if ($context) { |
| 153 | 148 | $result = $xob->query($xpath, $context); |
| 154 | - } |
|
| 155 | - else { |
|
| 149 | + } else { |
|
| 156 | 150 | $result = $xob->query($xpath); |
| 157 | 151 | } |
| 158 | 152 | |
| 159 | 153 | if ($result) { |
| 160 | 154 | return new DOMList($result, $this); |
| 161 | - } |
|
| 162 | - else { |
|
| 155 | + } else { |
|
| 163 | 156 | return FALSE; |
| 164 | 157 | } |
| 165 | 158 | } |
@@ -183,8 +176,7 @@ discard block |
||
| 183 | 176 | |
| 184 | 177 | if (empty($result) || !count($result)) { |
| 185 | 178 | return FALSE; |
| 186 | - } |
|
| 187 | - else { |
|
| 179 | + } else { |
|
| 188 | 180 | return $result->item(0); |
| 189 | 181 | } |
| 190 | 182 | } |
@@ -263,13 +255,11 @@ discard block |
||
| 263 | 255 | if ($context->hasChildNodes()) { |
| 264 | 256 | if ($context->childNodes->length == 1 && $context->firstChild->nodeType == XML_TEXT_NODE) { |
| 265 | 257 | $array['#text'] = $context->firstChild->nodeValue; |
| 266 | - } |
|
| 267 | - else { |
|
| 258 | + } else { |
|
| 268 | 259 | foreach ($context->childNodes as $childNode) { |
| 269 | 260 | if ($childNode->nodeType == XML_ELEMENT_NODE) { |
| 270 | 261 | $array[$childNode->nodeName][] = $this->getArray($raw, $childNode); |
| 271 | - } |
|
| 272 | - elseif ($childNode->nodeType == XML_CDATA_SECTION_NODE) { |
|
| 262 | + } elseif ($childNode->nodeType == XML_CDATA_SECTION_NODE) { |
|
| 273 | 263 | $array['#text'] = $childNode->textContent; |
| 274 | 264 | } |
| 275 | 265 | } |
@@ -301,8 +291,7 @@ discard block |
||
| 301 | 291 | $matches = array(); |
| 302 | 292 | if (preg_match($pattern, $this->saveXML($context), $matches)) { |
| 303 | 293 | return $matches[1]; |
| 304 | - } |
|
| 305 | - else { |
|
| 294 | + } else { |
|
| 306 | 295 | return ''; |
| 307 | 296 | } |
| 308 | 297 | } |
@@ -372,8 +361,7 @@ discard block |
||
| 372 | 361 | |
| 373 | 362 | if ($newnode->ownerDocument === $this) { |
| 374 | 363 | $appendnode = $newnode; |
| 375 | - } |
|
| 376 | - else { |
|
| 364 | + } else { |
|
| 377 | 365 | $appendnode = $this->importNode($newnode, true); |
| 378 | 366 | } |
| 379 | 367 | |
@@ -455,13 +443,11 @@ discard block |
||
| 455 | 443 | if ($context->nextSibling) { |
| 456 | 444 | // $context has an immediate sibling : insert newnode before this one |
| 457 | 445 | return $context->parentNode->insertBefore($newnode, $context->nextSibling); |
| 458 | - } |
|
| 459 | - else { |
|
| 446 | + } else { |
|
| 460 | 447 | // $context has no sibling next to it : insert newnode as last child of it's parent |
| 461 | 448 | if ($newnode->ownerDocument === $this) { |
| 462 | 449 | $appendnode = $newnode; |
| 463 | - } |
|
| 464 | - else { |
|
| 450 | + } else { |
|
| 465 | 451 | $appendnode = $this->importNode($newnode, true); |
| 466 | 452 | } |
| 467 | 453 | return $context->parentNode->appendChild($appendnode); |
@@ -529,11 +515,9 @@ discard block |
||
| 529 | 515 | foreach($node as $item) { |
| 530 | 516 | $this->remove($item); |
| 531 | 517 | } |
| 532 | - } |
|
| 533 | - else if (get_class($node) == 'DOMNodeList') { |
|
| 518 | + } else if (get_class($node) == 'DOMNodeList') { |
|
| 534 | 519 | $this->remove(new DOMList($node, $this)); |
| 535 | - } |
|
| 536 | - else { |
|
| 520 | + } else { |
|
| 537 | 521 | $parent = $node->parentNode; |
| 538 | 522 | $parent->removeChild($node); |
| 539 | 523 | } |
@@ -555,8 +539,7 @@ discard block |
||
| 555 | 539 | public function tranform($xsl, $context = NULL) { |
| 556 | 540 | if (!$context) { |
| 557 | 541 | $doc = $this; |
| 558 | - } |
|
| 559 | - else { |
|
| 542 | + } else { |
|
| 560 | 543 | if (is_string($context)) { |
| 561 | 544 | $context = $this->xpathSingle($context); |
| 562 | 545 | } |
@@ -607,8 +590,7 @@ discard block |
||
| 607 | 590 | |
| 608 | 591 | $transformed = $this->tranform($xsl, $node); |
| 609 | 592 | return $this->replace($node, $transformed->documentElement); |
| 610 | - } |
|
| 611 | - else { |
|
| 593 | + } else { |
|
| 612 | 594 | // @@TODO: Report the correct calling file and number |
| 613 | 595 | throw new Exception("Changing the namespace of a " . get_class($node) . " is not supported"); |
| 614 | 596 | } |
@@ -693,14 +675,12 @@ discard block |
||
| 693 | 675 | // Add in xlink options |
| 694 | 676 | if ($options['xlink'] === TRUE) { |
| 695 | 677 | $options['xlink'] = "@xlink:type = 'simple'"; |
| 696 | - } |
|
| 697 | - else if (empty($options['xlink'])) { |
|
| 678 | + } else if (empty($options['xlink'])) { |
|
| 698 | 679 | $options['xlink'] = "false()"; |
| 699 | 680 | } |
| 700 | 681 | $xslOptions = str_replace("||xlink||", $options['xlink'], $xslOptions); |
| 701 | 682 | $transformed = $this->tranform($xslOptions, $context); |
| 702 | - } |
|
| 703 | - else { |
|
| 683 | + } else { |
|
| 704 | 684 | $transformed = $this->tranform($xslSimple, $context); |
| 705 | 685 | } |
| 706 | 686 | |
@@ -736,8 +716,7 @@ discard block |
||
| 736 | 716 | // Find any of these elements that have no child nodes and are therefore candidates for self-closing, replace them with a self-closed version. |
| 737 | 717 | $pattern = '<(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)(\b[^<]*)><\/\1>'; |
| 738 | 718 | return preg_replace('/' . $pattern . '/', '<$1$2/>', $output); |
| 739 | - } |
|
| 740 | - else { |
|
| 719 | + } else { |
|
| 741 | 720 | return $this->saveXML($context, LIBXML_NOEMPTYTAG); |
| 742 | 721 | } |
| 743 | 722 | } |
@@ -753,8 +732,7 @@ discard block |
||
| 753 | 732 | // Check up error-checking |
| 754 | 733 | if ($error_checking == FALSE) { |
| 755 | 734 | $this->error_checking = 'none'; |
| 756 | - } |
|
| 757 | - else { |
|
| 735 | + } else { |
|
| 758 | 736 | $this->error_checking = $error_checking; |
| 759 | 737 | } |
| 760 | 738 | if ($this->error_checking != 'strict') { |
@@ -781,8 +759,7 @@ discard block |
||
| 781 | 759 | if ($namespace->prefix != 'xml' && $namespace->nodeValue != 'http://www.w3.org/XML/1998/namespace') { |
| 782 | 760 | $this->registerNamespace($namespace->prefix, $namespace->nodeValue); |
| 783 | 761 | } |
| 784 | - } |
|
| 785 | - else { |
|
| 762 | + } else { |
|
| 786 | 763 | $this->default_ns = $namespace->nodeValue; |
| 787 | 764 | if (is_string($auto_register_namespaces)) { |
| 788 | 765 | $this->registerNamespace($auto_register_namespaces, $namespace->nodeValue); |
@@ -813,8 +790,7 @@ discard block |
||
| 813 | 790 | $this->registerNamespace($tagname, $attr->value); |
| 814 | 791 | } |
| 815 | 792 | } |
| 816 | - } |
|
| 817 | - else if (substr($attr->name,0,6) == 'xmlns:') { |
|
| 793 | + } else if (substr($attr->name,0,6) == 'xmlns:') { |
|
| 818 | 794 | $prefix = substr($attr->name,6); |
| 819 | 795 | $this->registerNamespace($prefix, $attr->value); |
| 820 | 796 | } |