public static function stylesToDOM($files = array())
    {
        foreach ($files as $primary => &$v) {
            if (!$v instanceof DomDocument) {
                $dom = new DomDocument();
                $dom->load($v);
            } else {
                $dom = $v;
            }

            if ($dom->firstChild->nodeName === 'xsl:stylesheet') {
                break;
            }

            unset($primary);
        }

        if (!isset($primary)) {
            throw new RuntimeException('No valid XML stylesheets were found for XSLT parser.');
        }

        foreach ($files as $k => &$v) {
            if ($k === $primary) {
                continue;
            }

            if ($v instanceof DomDocument) {
                if ($v->firstChild->nodeName !== 'xsl:stylesheet') {
                    continue;
                }

                foreach ($v->firstChild->childNodes as $include) {
                    $dom->appendChild($dom->importNode($include, true));
                }
            } else {
                $include = $dom->createElementNS('http://www.w3.org/1999/XSL/Transform', 'xsl:include');
                $include->setAttributeNode(new DomAttr('href', $v));
                $dom->firstChild->appendChild($include);
            }
        }

        return $dom;
    }
public static function stylesToDOM($files = array())
    {
        foreach ($files as $primary => &$v) {
            if (!$v instanceof DomDocument) {
                $dom = new DomDocument();
                $dom->load($v);
            } else {
                $dom = $v;
            }

            if ($dom->firstChild->nodeName === 'xsl:stylesheet') {
                break;
            }

            unset($primary);
        }

        if (!isset($primary)) {
            throw new RuntimeException('No valid XML stylesheets were found for XSLT parser.');
        }

        foreach ($files as $k => &$v) {
            if ($k === $primary) {
                continue;
            }

            if ($v instanceof DomDocument) {
                if ($v->firstChild->nodeName !== 'xsl:stylesheet') {
                    continue;
                }

                foreach ($v->firstChild->childNodes as $include) {
                    $dom->appendChild($dom->importNode($include, true));
                }
            } else {
                $include = $dom->createElementNS('http://www.w3.org/1999/XSL/Transform', 'xsl:include');
                $include->setAttributeNode(new DomAttr('href', $v));
                $dom->firstChild->appendChild($include);
            }
        }

        return $dom;
    }
public static function stylesToDOM ( $ files = array ( ) ) { foreach ( $ files as $ primary => & $ v ) { if ( ! $ v instanceof DomDocument ) { $ dom = new DomDocument ( ) ; $ dom -> load ( $ v ) ; } else { $ dom = $ v ; } if ( $ dom -> firstChild -> nodeName === 'xsl:stylesheet' ) { break ; } unset ( $ primary ) ; } if ( ! isset ( $ primary ) ) { throw new RuntimeException ( 'No valid XML stylesheets were found for XSLT parser.' ) ; } foreach ( $ files as $ k => & $ v ) { if ( $ k === $ primary ) { continue ; } if ( $ v instanceof DomDocument ) { if ( $ v -> firstChild -> nodeName !== 'xsl:stylesheet' ) { continue ; } foreach ( $ v -> firstChild -> childNodes as $ include ) { $ dom -> appendChild ( $ dom -> importNode ( $ include , true ) ) ; } } else { $ include = $ dom -> createElementNS ( 'http://www.w3.org/1999/XSL/Transform' , 'xsl:include' ) ; $ include -> setAttributeNode ( new DomAttr ( 'href' , $ v ) ) ; $ dom -> firstChild -> appendChild ( $ include ) ; } } return $ dom ; }
Converts XSL files to DomDocument.

@param mixed $files Either single file path as string or array of files, files can also be DomDocuments

@return DomDocument
Converts XSL files to DomDocument .