views:

354

answers:

1

Hi,

I'm 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]: compilation error: file /home/..../xsl/1234567890.xsl line 2 element stylesheet 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"&gt;
<xsl:template match="/">
</xsl:template>
</xsl:stylesheet>

I've currently trimmed it down to this "nothing" in order to diagnose where the problem occurs, but it still remains in this "basic" XSL version!

A: 

Hi,

It seems to load fine if you replace the xsl:stylesheet line with this one :

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

Which means having this xsl file :

<?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 transform you file ?


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

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

Pascal MARTIN
Awesomeness! That *DID* work! Thanks Pascal!!
Steve
You're welcome :-)
Pascal MARTIN