[ Index ] |
PHP Cross Reference of phpBB-3.3.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package s9e\TextFormatter 5 * @copyright Copyright (c) 2010-2022 The s9e authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\TextFormatter\Configurator\TemplateNormalizations; 9 10 use DOMElement; 11 use DOMException; 12 13 /** 14 * Inline the elements declarations of a template 15 * 16 * Will replace 17 * <xsl:element name="div"><xsl:apply-templates/></xsl:element> 18 * with 19 * <div><xsl:apply-templates/></div> 20 */ 21 class InlineElements extends AbstractNormalization 22 { 23 /** 24 * {@inheritdoc} 25 */ 26 protected $queries = ['//xsl:element']; 27 28 /** 29 * {@inheritdoc} 30 */ 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 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Jun 23 12:25:44 2024 | Cross-referenced by PHPXref 0.7.1 |