PHP warning in XSLTProcessor :: importStylesheet () despite nearly empty XSL stylesheet

I am trying to use the following code

# LOAD XML FILE
$XML = new DOMDocument();
$XML->loadXML( $exporteddatatransformed );

# START XSLT
$xslt = new XSLTProcessor();
$XSL = new DOMDocument();
$XSL->load( 'xsl/'.$xsltemplatefileid.'.xsl', LIBXML_NOCDATA);
$xslt->importStylesheet( $XSL );            <-- LINE 549
#PRINT
print $xslt->transformToXML( $XML );

      

But it generates the following error.

Warning: XSLTProcessor :: importStylesheet () [xsltprocessor.importstylesheet]: compile error: file /home/..../xsl/1234567890.xsl line 2 element style styles in /home/...../myfile. php on line 549

The XSL sheet looks like this:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
</xsl:template>
</xsl:stylesheet> 

      

I have now trimmed that "nothing" to diagnose where the problem is, but it still remains in this "base" version of XSL!

+2


source to share


1 answer


It seems to be ok if you replace the xsl: stylesheet line with the following:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

      

What does the presence of this xsl file mean:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    </xsl:template>
</xsl:stylesheet>

      



Instead of yours.

Does it work when you try to convert a file?


Note. I don't use XSL often, so I'm not sure why what you suggested doesn't work; but http://www.w3.org/1999/XSL/Transform "is used both in the wikipedia article on XSL Transformations , and in the example .xsl file used in the PHP manual ...

So, I guess this should help solve your problem, even if I don't really know "why" ^^

0


source







All Articles