public function toDOM($applystyles = true)
    {
        if ($applystyles && !empty($this->styles)) {
            $proc = self::stylesToProc($this->styles);
            $proc->registerPhpFunctions();
        }

        switch ($this->sourceType) {
            case self::SOURCE_TYPE_DOM:
                if ($this->source instanceof DomDocument) {
                    return $this->source;
                }

                // when parameter for constructor was DomNode
                $dom = new DomDocument('1.0', 'utf-8');
                $dome = $dom->importNode($this->source, true);
                $dom->appendChild($dome);

                return $dom;
            case self::SOURCE_TYPE_SIMPLEXML:
                // @todo detect charset from simplexml?
                $dom = new DomDocument('1.0', 'utf-8');
                $dome = dom_import_simplexml($this->source);
                $dome = $dom->importNode($dome, true);
                $dom->appendChild($dome);

                return $dom;
            case self::SOURCE_TYPE_OBJECT:
                $dom = $this->objectToDom($this->source);
                break;
            case self::SOURCE_TYPE_FILE:
                $dom = new DomDocument();
                $dom->load($this->source);
                break;
            case self::SOURCE_TYPE_STRING:
                $dom = new DomDocument();
                $dom->loadXML($this->source);
        }

        return isset($proc) ? $proc->transformToDoc($dom) : $dom;
    }
public function toDOM($applystyles = true)
    {
        if ($applystyles && !empty($this->styles)) {
            $proc = self::stylesToProc($this->styles);
            $proc->registerPhpFunctions();
        }

        switch ($this->sourceType) {
            case self::SOURCE_TYPE_DOM:
                if ($this->source instanceof DomDocument) {
                    return $this->source;
                }

                // when parameter for constructor was DomNode
                $dom = new DomDocument('1.0', 'utf-8');
                $dome = $dom->importNode($this->source, true);
                $dom->appendChild($dome);

                return $dom;
            case self::SOURCE_TYPE_SIMPLEXML:
                // @todo detect charset from simplexml?
                $dom = new DomDocument('1.0', 'utf-8');
                $dome = dom_import_simplexml($this->source);
                $dome = $dom->importNode($dome, true);
                $dom->appendChild($dome);

                return $dom;
            case self::SOURCE_TYPE_OBJECT:
                $dom = $this->objectToDom($this->source);
                break;
            case self::SOURCE_TYPE_FILE:
                $dom = new DomDocument();
                $dom->load($this->source);
                break;
            case self::SOURCE_TYPE_STRING:
                $dom = new DomDocument();
                $dom->loadXML($this->source);
        }

        return isset($proc) ? $proc->transformToDoc($dom) : $dom;
    }
public function toDOM ( $ applystyles = true ) { if ( $ applystyles && ! empty ( $ this -> styles ) ) { $ proc = self :: stylesToProc ( $ this -> styles ) ; $ proc -> registerPhpFunctions ( ) ; } switch ( $ this -> sourceType ) { case self :: SOURCE_TYPE_DOM : if ( $ this -> source instanceof DomDocument ) { return $ this -> source ; } // when parameter for constructor was DomNode $ dom = new DomDocument ( '1.0' , 'utf-8' ) ; $ dome = $ dom -> importNode ( $ this -> source , true ) ; $ dom -> appendChild ( $ dome ) ; return $ dom ; case self :: SOURCE_TYPE_SIMPLEXML : // @todo detect charset from simplexml? $ dom = new DomDocument ( '1.0' , 'utf-8' ) ; $ dome = dom_import_simplexml ( $ this -> source ) ; $ dome = $ dom -> importNode ( $ dome , true ) ; $ dom -> appendChild ( $ dome ) ; return $ dom ; case self :: SOURCE_TYPE_OBJECT : $ dom = $ this -> objectToDom ( $ this -> source ) ; break ; case self :: SOURCE_TYPE_FILE : $ dom = new DomDocument ( ) ; $ dom -> load ( $ this -> source ) ; break ; case self :: SOURCE_TYPE_STRING : $ dom = new DomDocument ( ) ; $ dom -> loadXML ( $ this -> source ) ; } return isset ( $ proc ) ? $ proc -> transformToDoc ( $ dom ) : $ dom ; }
Converts source to DomDocument.

@param bool $applystyles Apply stylesheets yes/no. Default is true.

@return DomDocument

@todo support for passing XsltProcessor as parameter
Converts source to DomDocument .