appendChild($d->createElement("html")); try { $a = $d->createAttributeNS($namespaceURI, $qualifiedName); // @codeCoverageIgnoreStart } catch (\DOMException $e) { // The attribute name is invalid for XML 1.0 Second Edition // Replace any offending characters with "UHHHHHH" where H are the // uppercase hexadecimal digits of the character's code point // NOTE: This case is never encountered by the parser $qualifiedName = self::coerceName($qualifiedName, true); $a = $d->createAttributeNS($namespaceURI, $qualifiedName); } // @codeCoverageIgnoreEnd $a->value = self::escapeString($value, true); $element->setAttributeNodeNS($element->ownerDocument->importNode($a)); } else { try { $element->setAttributeNS($namespaceURI, $qualifiedName, $value); } catch (\DOMException $e) { // The attribute name is invalid for XML 1.0 Second Edition // Replace any offending characters with "UHHHHHH" where H are the // uppercase hexadecimal digits of the character's code point $qualifiedName = self::coerceName($qualifiedName, ($namespaceURI !== null)); $element->setAttributeNS($namespaceURI, $qualifiedName, $value); $this->mangledAttributes = true; } if ($qualifiedName === "id" && $namespaceURI === null) { $element->setIdAttribute($qualifiedName, true); } } } }