Save Dom as XHTML file.

@param \DOMDocument $dom
@param string $name

@return bool|string
343585
public function saveDom( \DOMDocument $dom, $name ){
		return $this->distributor->write($this->convertToString($dom), "OEBPS/Text/{$name}");
	}
705511
public function toXML( DOMDocument $dom )
    {
        $blockNode = $dom->createElement( 'block' );

        foreach ( $this->attributes as $attrName => $attrValue )
        {
            switch ( $attrName )
            {
                case 'id':
                    $blockNode->setAttribute( 'id', 'id_' . $attrValue );
                    break;

                case 'action':
                    $blockNode->setAttribute( 'action', $attrValue );
                    break;

                case 'items':
                    foreach ( $this->attributes['items'] as $item )
                    {
                        $itemNode = $item->toXML( $dom );
                        if ( $itemNode )
                        {
                            $blockNode->appendChild( $itemNode );
                        }
                    }
                    break;

                case 'rotation':
                    $node = $dom->createElement( $attrName );
                    $blockNode->appendChild( $node );

                    foreach ( $attrValue as $arrayItemKey => $arrayItemValue )
                    {
                        $tmp = $dom->createElement( $arrayItemKey );
                        $tmpValue = $dom->createTextNode( $arrayItemValue );
                        $tmp->appendChild( $tmpValue );
                        $node->appendChild( $tmp );
                    }
                    break;

                case 'custom_attributes':
                    $node = $dom->createElement( $attrName );
                    $blockNode->appendChild( $node );

                    foreach ( $attrValue as $arrayItemKey => $arrayItemValue )
                    {
                        $tmp = $dom->createElement( $arrayItemKey );
                        $tmpValue = $dom->createTextNode( $arrayItemValue );
                        $tmp->appendChild( $tmpValue );
                        $node->appendChild( $tmp );
                    }
                    break;

                default:
                    $node = $dom->createElement( $attrName );
                    $nodeValue = $dom->createTextNode( $attrValue );
                    $node->appendChild( $nodeValue );
                    $blockNode->appendChild( $node );
                    break;
            }
        }

        return $blockNode;
    }
308847
public function saveHTML( $dom ) {
		if ( $this->parser instanceof \DOMDocument ) {
			libxml_use_internal_errors( true );
			$html = $dom->saveHTML();
			$this->errors = libxml_get_errors();
			libxml_clear_errors();
		} else {
			$html = $this->parser->saveHTML( $dom );
		}

		$html = \Pressbooks\Sanitize\strip_container_tags( $html );

		$replace_pairs = [
			'<div><!-- pb_fixme -->' => '',
			'<!-- pb_fixme --></div>' => '',
		];
		$html = strtr( $html, $replace_pairs );

		return $html;
	}
233918
static function render($node, &$document = null)
    {
        $document = $document ?: new \DOMDocument;
        $document->appendChild(static::renderNode($node, $document));

        return $document->saveHTML();
    }
786716
protected function createElement($name)
    {
        if (isset($this->elements[$name])) {
            return $this->factory->createInlineElement($this->elements[$name]);
        }

        return $this->factory->createElement($name);
    }
786317
public function toXML(DOMDocument $doc, $nodeName = "")
    {
        $text = $doc->createTextNode(gmdate("Y-m-d\TH:i:s\Z", $this->getValue()));
        $node = $doc->createElement("date");
        $node->appendChild($text);
        return $node;
    }
539974
private function createBooleanNode(\DOMDocument $document, bool $value, string $name = null): \DOMNode
    {
        $node = $document->createElement('json:boolean', $value ? 'true' : 'false');

        if (null !== $name) {
            $node->setAttribute('name', $name);
        }

        return $node;
    }
161247
public function createInsertTarget(string $name)
    {
        if (!$this->loaded) {
            $this->loadHTML('');
        }
        $element = $this->createElement('html5-dom-document-insert-target');
        $element->setAttribute('name', $name);
        return $element;
    }
749687
protected function buildNamespaceTree(\DOMDocument $dom)
    {
        $xpath = new \DOMXPath($dom);
        $namespaces = array();
        $qry = $xpath->query('//@namespace');
        for ($i = 0; $i < $qry->length; $i++) {
            if (isset($namespaces[$qry->item($i)->nodeValue])) {
                continue;
            }

            $namespaces[$qry->item($i)->nodeValue] = true;
        }

        $namespaces = $this->generateNamespaceTree(array_keys($namespaces));
        $this->generateNamespaceElements($namespaces, $dom->documentElement);
    }
904206
static function laraform($html, $name = null) {
        $el = new ElementStaticTwbs($name ? $name : uniqid());
        $el->setValue($html);

        return $el;
    }
688601
protected function store($content, $name = null)
    {
        $name = (is_null($name)) ? $this->name() : $name;
        $file = fopen($this->TemplateDir.'/'.$name, 'w');
        //
        fwrite($file, $content);
        fclose($file);
        //
        return $this->TemplateDir.'/'.$name;
    }
576869
private function getChildrenValues(\DOMNode $node, $name)
    {
        $children = array();
        foreach ($node->childNodes as $child) {
            if ($child instanceof \DOMElement && $child->localName === $name) {
                $children[] = $child->nodeValue;
            }
        }

        return $children;
    }
92079
public function getXML(){
		$doc = new \DomDocument('1.0');
		$doc->preserveWhiteSpace = false;
		$doc->formatOutput = true;
		$doc->loadXML($this->dom->asXml());
		return $doc->saveXML();
	}
271561
protected function getFormGroupWithoutLabel($name, $element)
    {
        $options = $this->getFormGroupOptions($name);

        return $this->toHtmlString('<div' . $this->html->attributes($options) . '>' . $element . '</div>');
    }
1249492
public static function element($name) {
        if (isset(static::$html5[$name])) {
            return static::$html5[$name];
        }
        if (isset(static::$svg[$name])) {
            return static::$svg[$name];
        }
        if (isset(static::$mathml[$name])) {
            return static::$mathml[$name];
        }

        return false;
    }
1314969
protected function renderHtml($name = null, $data = []) {
        if (is_array($name)) {
            $data = $name;
            $name = null;
        }
        return $this->renderFile($this->getViewFile($name), $data);
    }
1234747
public function getHtml($name = null)
    {
        $host = self::API_SERVER;

        $langOption = '';

        if (isset($this->options['lang']) && ! empty($this->options['lang'])) {
            $langOption = "?hl={$this->options['lang']}";
        }

        $return = <<<HTML
<script type="text/javascript" src="{$host}{$langOption}" async defer></script>
HTML;

        return $return;
    }