Append this attribute value to an element.

@param  \DOMElement $parent The element we should append this attribute value to.
@return \DOMElement The generated AttributeValue element.
342915
public function toXML(DOMElement $parent) : DOMElement
    {
        Assert::same($this->getElement()->namespaceURI, Constants::NS_SAML);
        Assert::same($this->getElement()->localName, "AttributeValue");

        return Utils::copyElement($this->element, $parent);
    }
544745
protected function _generateBlock($node, $parent)
    {
        if ($node instanceof Mage_Core_Model_Layout_Element) {
            if (!$this->checkConditionals($node)) {
                return $this;
            }
        }

        return parent::_generateBlock($node, $parent);
    }
1188813
public function prepend(DOMElement &$parent, &$child)
    {
        if (empty($child)) {
            throw new InvalidArgumentException('You are trying to prepend an empty element.');
        }

        // Append before first child
        if ($parent->childNodes->length > 0) {
            $parent->insertBefore($child, $parent->childNodes->item(0));
        } else {
            $this->append($parent, $child);
        }

        // Return the DOMElement
        return $parent;
    }
582244
public function bindParent($parent, $parentPropertyName=NULL)
	{
		$this->_parent = $parent;
		$this->_parentPropertyName = $parentPropertyName;
		return $this;
	}
1264609
public function toXML(DOMElement $parent) : DOMElement
    {
        $doc = $parent->ownerDocument;

        $e = $doc->createElementNS(Constants::NS_MD, 'md:ContactPerson');
        $parent->appendChild($e);

        $e->setAttribute('contactType', $this->getContactType());

        foreach ($this->getContactPersonAttributes() as $attr => $val) {
            $e->setAttribute($attr, $val);
        }

        Extensions::addList($e, $this->getExtensions());

        if ($this->Company !== null) {
            Utils::addString($e, Constants::NS_MD, 'md:Company', $this->Company);
        }
        if ($this->GivenName !== null) {
            Utils::addString($e, Constants::NS_MD, 'md:GivenName', $this->GivenName);
        }
        if ($this->SurName !== null) {
            Utils::addString($e, Constants::NS_MD, 'md:SurName', $this->SurName);
        }
        if (!empty($this->getEmailAddress())) {
            Utils::addStrings($e, Constants::NS_MD, 'md:EmailAddress', false, $this->getEmailAddress());
        }
        if (!empty($this->getTelephoneNumber())) {
            Utils::addStrings($e, Constants::NS_MD, 'md:TelephoneNumber', false, $this->getTelephoneNumber());
        }

        return $e;
    }
1200534
public function setParent($parent)
    {
        if (null !== $parent) {
            $this->entity->setParent($parent->getEntity());
        } else {
            $this->entity->setParent(null);
        }

        // FIXME remove cache for parent and generate it on the fly
        //       reason: preview images cannot be generated without a service
        $this->parent = $parent;

        return $this;
    }
402009
public function toXML(DOMElement $parent = null) : DOMElement
    {
        if ($parent === null) {
            $parent = DOMDocumentFactory::create();
            $doc = $parent;
        } else {
            $doc = $parent->ownerDocument;
        }
        $element = $doc->createElementNS(Constants::NS_SAML, $this->nodeName);
        $parent->appendChild($element);

        if ($this->NameQualifier !== null) {
            $element->setAttribute('NameQualifier', $this->NameQualifier);
        }

        if ($this->SPNameQualifier !== null) {
            $element->setAttribute('SPNameQualifier', $this->SPNameQualifier);
        }

        return $element;
    }
1310000
protected function appendHTML(DOMElement $elem, string $html): DOMElement
   {
       try {
           $dom = new DOMDocument();
           $this->loadHTML($dom, $html);
           foreach($dom->childNodes as $node) {
               if ($node instanceof DOMElement) {
                   $elem->appendChild($this->template->createTextNode("\n"));
                   $elem->appendChild($this->template->importNode($node, true));
               }
           }
           return $elem;
       } catch (Throwable $e) {
           throw new RuntimeException("Can't append HTML: " . $e->getMessage());
       }
   }
472479
private function addElement($name, $parent = false, $ns = false)
    {
        if ($ns) {
            $el = $this->doc->createElementNS($ns, $name);
        } else {
            $el = $this->doc->createElement($name);
        }
        if ($parent) {
            $parent->appendChild($el);
        }

        return $el;
    }
1098291
protected function appendAttributesToElementToSend(\DOMElement $element)
    {
        if ($this->hasAttributes()) {
            foreach ($this->getAttributes() as $attributeName => $attributeValue) {
                $matches = [];
                if (0 === preg_match(sprintf('/(%s|%s):/', self::NS_WSSU_NAME, self::NS_WSSE_NAME), $attributeName, $matches)) {
                    $element->setAttribute($attributeName, $attributeValue);
                } else {
                    $element->setAttributeNS(self::NS_WSSE_NAME === $matches[1] ? self::NS_WSSE : self::NS_WSSU, $attributeName, $attributeValue);
                }
            }
        }

        return $this;
    }
864553
public function convert(\DOMElement $parent, PropertyDescriptor $property)
    {
        $fullyQualifiedNamespaceName = $property->getNamespace() instanceof NamespaceDescriptor
            ? $property->getNamespace()->getFullyQualifiedStructuralElementName()
            : $parent->getAttribute('namespace');

        $child = new \DOMElement('property');
        $parent->appendChild($child);

        $child->setAttribute('static', var_export($property->isStatic(), true));
        $child->setAttribute('visibility', $property->getVisibility());
        $child->setAttribute('namespace', $fullyQualifiedNamespaceName);
        $child->setAttribute('line', (string) $property->getLine());

        $child->appendChild(new \DOMElement('name', '$' . $property->getName()));
        $child->appendChild(new \DOMElement('full_name', (string) $property->getFullyQualifiedStructuralElementName()));
        $child->appendChild(new \DOMElement('default'))->appendChild(new \DOMText((string) $property->getDefault()));

        $this->docBlockConverter->convert($child, $property);

        return $child;
    }
956982
protected final function appendXMLTo(
       SimpleXMLElement $parent,
       string $child): SimpleXMLElement
   {
       return $this->appendTo(
           $parent,
           simplexml_load_string(str_replace("\n", "\n\t", $child)));
   }
990708
public static function copyElement(DOMElement $element, DOMElement $parent = null) : DOMElement
    {
        if ($parent === null) {
            $document = DOMDocumentFactory::create();
        } else {
            $document = $parent->ownerDocument;
        }

        $namespaces = [];
        for ($e = $element; $e instanceof DOMNode; $e = $e->parentNode) {
            foreach (Utils::xpQuery($e, './namespace::*') as $ns) {
                $prefix = $ns->localName;
                if ($prefix === 'xml' || $prefix === 'xmlns') {
                    continue;
                }
                $uri = $ns->nodeValue;
                if (!isset($namespaces[$prefix])) {
                    $namespaces[$prefix] = $uri;
                }
            }
        }

        /** @var \DOMElement $newElement */
        $newElement = $document->importNode($element, true);
        if ($parent !== null) {
            /* We need to append the child to the parent before we add the namespaces. */
            $parent->appendChild($newElement);
        }

        foreach ($namespaces as $prefix => $uri) {
            $newElement->setAttributeNS($uri, $prefix.':__ns_workaround__', 'tmp');
            $newElement->removeAttributeNS($uri, '__ns_workaround__');
        }

        return $newElement;
    }
186223
public function toXML(DOMElement $parent = null) : DOMElement
    {
        if (empty($this->entityID)) {
            throw new \Exception('Cannot convert EntityDescriptor to XML without an EntityID set.');
        }

        if ($parent === null) {
            $doc = DOMDocumentFactory::create();
            $e = $doc->createElementNS(Constants::NS_MD, 'md:EntityDescriptor');
            $doc->appendChild($e);
        } else {
            $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, 'md:EntityDescriptor');
            $parent->appendChild($e);
        }

        $e->setAttribute('entityID', $this->entityID);

        if ($this->ID !== null) {
            $e->setAttribute('ID', $this->ID);
        }

        if ($this->validUntil !== null) {
            $e->setAttribute('validUntil', gmdate('Y-m-d\TH:i:s\Z', $this->validUntil));
        }

        if ($this->cacheDuration !== null) {
            $e->setAttribute('cacheDuration', $this->cacheDuration);
        }

        Extensions::addList($e, $this->Extensions);

        foreach ($this->RoleDescriptor as $n) {
            $n->toXML($e);
        }

        if ($this->AffiliationDescriptor !== null) {
            $this->AffiliationDescriptor->toXML($e);
        }

        if ($this->Organization !== null) {
            $this->Organization->toXML($e);
        }

        foreach ($this->ContactPerson as $cp) {
            $cp->toXML($e);
        }

        foreach ($this->AdditionalMetadataLocation as $n) {
            $n->toXML($e);
        }

        /** @var \DOMElement $child */
        $child = $e->firstChild;
        $this->signElement($e, $child);

        return $e;
    }
1236757
public function toXML(DOMElement $parent) : DOMElement
    {
        $e = parent::toXML($parent);

        if (is_bool($this->AuthnRequestsSigned)) {
            $e->setAttribute('AuthnRequestsSigned', $this->AuthnRequestsSigned ? 'true' : 'false');
        }

        if (is_bool($this->WantAssertionsSigned)) {
            $e->setAttribute('WantAssertionsSigned', $this->WantAssertionsSigned ? 'true' : 'false');
        }

        foreach ($this->AssertionConsumerService as $ep) {
            $ep->toXML($e, 'md:AssertionConsumerService');
        }

        foreach ($this->AttributeConsumingService as $acs) {
            $acs->toXML($e);
        }

        return $e;
    }
685781
public function addTo (Component $parent)
    {
        $parent->add($this);
        $this->parent = $parent;
        return $this;
    }
1345975
public function makeChild(array $attributes=[], $parent)
    {
        $child = $this->model()->makeChild($attributes, $parent);
        $this->callAfterListeners('make', [$child]);
        return $child;
    }