Get namespace attributes from root element or specific element

@param \DOMElement $element
@throws \Inphinit\Experimental\Exception
@return void
772898
public function getNamespaces(\DOMElement $element = null)
    {
        if ($this->xpath === null) {
            $this->xpath = new \DOMXPath($this);
        }

        if ($element === null) {
            $nodes = $this->xpath->query('namespace::*');
        } else {
            $nodes = $this->xpath->query('namespace::*', $element);
        }

        $ns = array();

        if ($nodes) {
            foreach ($nodes as $node) {
                $arr = $element->getAttribute($node->nodeName);

                if ($arr) {
                    $ns[$node->nodeName] = $arr;
                }
            }

            $nodes = null;
        }

        return $ns;
    }
185265
protected function processNode(DOMElement $element, SanitizerOptions $options)
    {
        $elementName = strtolower((string) $element->localName);
        if (!in_array($elementName, $options->getElementWhitelist(), true) && in_array($elementName, $options->getUnsafeElements(), true)) {
            $element->parentNode->removeChild($element);
        } else {
            foreach ($element->attributes as $attribute) {
                /* @var \DOMAttr $attribute */
                $attributeName = strtolower((string) $attribute->localName);
                if (!in_array($attributeName, $options->getAttributeWhitelist(), true) && in_array($attributeName, $options->getUnsafeAttributes(), true)) {
                    $element->removeAttribute($attribute->name);
                }
            }
            $childElements = [];
            foreach ($element->childNodes as $childNode) {
                if ($childNode instanceof DOMElement) {
                    $childElements[] = $childNode;
                }
            }
            foreach ($childElements as $childElement) {
                $this->processNode($childElement, $options);
            }
        }
    }
286482
private static function convertNode(XMLElement $element, DOMNode $node)
    {
        if ($node->hasAttributes()) {
            foreach ($node->attributes as $name => $attrEl) {
                $element->setAttribute($name, General::sanitize($attrEl->value));
            }
        }

        if ($node->hasChildNodes()) {
            foreach ($node->childNodes as $childNode) {
                if ($childNode instanceof DOMCdataSection) {
                    $element->setValue(General::wrapInCDATA($childNode->data));
                } elseif ($childNode instanceof DOMText) {
                    if ($childNode->isWhitespaceInElementContent() === false) {
                        $element->setValue(General::sanitize($childNode->data));
                    }
                } elseif ($childNode instanceof DOMElement) {
                    self::convert($element, $childNode);
                }
            }
        }
    }
1017898
protected function elementStylesToAttribute( DOMElement $element )
    {
        $styleString = $element->getAttribute( 'style' );
        if ( $styleString )
        {
            $styleArray = explode( ';', $styleString );
            foreach( $styleArray as $style )
            {
                if ( !$style )
                    continue;

                list( $name, $value ) = explode( ':', $style );
                $name  = strtolower( trim( $name ) );
                $value = trim( $value );

                if ( $name === 'float' || $name === 'text-align' )
                    $name = 'align';

                if ( $name )
                {
                    try
                    {
                        $element->setAttribute( $name, $value );
                    }
                    catch (DOMException $e)
                    {
                        $this->handleError( self::ERROR_DATA, $e->getMessage() );
                    }
                }
            }
        }
    }
672135
protected function processPrefix(\DOMElement $element, ContextInterface $context)
    {
        if ($element->hasAttribute('prefix') && ($context instanceof RdfaLiteContext)) {
            $prefixes = preg_split('/\s+/', $element->getAttribute('prefix'));
            while (count($prefixes)) {
                $prefix = rtrim(array_shift($prefixes), ':');
                $uri = array_shift($prefixes);
                $context = $context->registerVocabulary($prefix, $uri);
            }
        }

        return $context;
    }
885598
protected static function getProperties(DOMElement $element)
	{
		return (isset(self::$htmlElements[$element->nodeName])) ? self::$htmlElements[$element->nodeName] : self::$htmlElements['span'];
	}
257994
protected function getElementAttribute(DomElement $element, $attributeName)
    {
        // First try to return for link
        if ($element->localName === 'link') {
            return $element->getAttribute($attributeName);
        }

        // Second return for embed
        return $element->getAttribute(EmbedLinking::TEMP_PREFIX . $attributeName);
    }
35942
protected function elementHasSafeUrl(DOMElement $element)
	{
		return $element->firstChild instanceof DOMText && $this->isSafeUrl($element->firstChild->textContent);
	}
1112845
private function extractAttributes(\DOMElement $node, array $data, $nodeName)
    {
        foreach ($data['@attributes'] as $key => $value) {

            if (! $this->isValidTagName($key)) {

                throw new \Exception(__CLASS__.' Illegal character in attribute name. attribute: '.$key.' in node: '.$nodeName);

            }

            $node->setAttribute($key, $this->boolToString($value));
        }
    }
154379
private function _getNodeAttributes(DOMElement $pNode)
    {
        $attributes = array();
        if ($pNode->attributes->length) {
            foreach ($pNode->attributes as $key => $attr) {
                $attributes[$key] = $attr->value;
            }
        }

        return $attributes;
    }
547909
private function getXMLLanguageList(SimpleXMLElement $element)
    {
        $this->xml_language_list = new CNabuXMLLanguageList(new CNabuLanguageList());
        $this->xml_language_list->collect($element);
    }
102415
public function xmlName($element)
    {
        list($ns, $localName) = XmlService::parseClarkNotation($element);
        if (isset($this->namespaceMap[$ns])) {
            $propName = $this->namespaceMap[$ns].':'.$localName;
        } else {
            $propName = $element;
        }

        return '<span title="'.$this->h($element).'">'.$this->h($propName).'</span>';
    }
1094696
public function parseElement(Node $parent, \DOMElement $element)
    {
        foreach ($this->registry[ElementExtension::class] as $extension) {
            $node = $extension->parseElement($parent, $element);
            if ($node) {
                return $node;
            }
        }

        return null;
    }
334206
public static function getInnerHtml(\DOMElement $element) {
    $innerHTML= '';
    $children = $element->childNodes;
    foreach ($children as $child) {
      $innerHTML .= $child->ownerDocument->saveXML( $child );
    }
    return $innerHTML;
  }
645026
private function addNamespaceAttributes(ClassMetadata $metadata, \DOMElement $element): void
    {
        foreach ($metadata->xmlNamespaces as $prefix => $uri) {
            $attribute = 'xmlns';
            if ('' !== $prefix) {
                $attribute .= ':' . $prefix;
            } elseif ($element->namespaceURI === $uri) {
                continue;
            }
            $element->setAttributeNS('http://www.w3.org/2000/xmlns/', $attribute, $uri);
        }
    }
593
protected function parseArgs(DOMElement $element)
    {
        $args = XmlUtil::getChildElements($element, 'arg');
        foreach ($args as $arg) {
            $name = XmlUtil::getRequiredAttributeValue($arg, 'name');
            $this->args[$name] = XmlUtil::getText($arg);
        }
    }
888557
public function parseElement(Node $parent, \DOMElement $element)
    {
        if (AtomPub::NS === $element->namespaceURI) {
            switch ($element->localName) {
                case 'collection':
                    // Node name already checked
                    return new Collection($parent, $element);
                case 'workspace':
                    // Node name already checked
                    return new Workspace($parent, $element);
            }
        }

        return null;
    }