protected function toXMLInternal(DOMElement $parent, string $namespace, string $name) : DOMElement
    {
        $e = $parent->ownerDocument->createElementNS($namespace, $name);
        $parent->appendChild($e);

        if (empty($this->Name)) {
            throw new \Exception('Cannot convert Attribute to XML with no Name set.');
        }
        $e->setAttribute('Name', $this->Name);

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

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

        foreach ($this->AttributeValue as $av) {
            $av->toXML($e);
        }

        return $e;
    }