Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP XSLTProcessor::importStylesheet(): compilation error

Tags:

php

xml

xslt

I'm trying to import a XSLT stylesheet, but still getting this error...

PHP:

//cadena original
        $xsl = new \DOMDocument();
        $xsl->load('storage/utils/cadenaoriginal_3_3.xslt');        
        // Crear el procesador XSLT que nos generará la cadena original con base en las reglas descritas en el XSLT
        $proc = new \XSLTProcessor();
        // Cargar las reglas de transformación desde el archivo XSLT.
        $proc->importStyleSheet($xsl);

XSLT: url: http://www.sat.gob.mx/sitio_internet/cfd/3/cadenaoriginal_3_3/cadenaoriginal_3_3.xslt

Any idea? :( This is the XSLT used by the goberment, so, it shouldn't have anything wrong inside, but can someone see someting weird or so?

like image 728
Ernesto Guerra Avatar asked Dec 06 '25 10:12

Ernesto Guerra


1 Answers

The stylesheet says version="2.0" which probably means it was written for an XSLT 2.0 processor. PHP based on libxslt supports only XSLT 1.0. In theory an XSLT 1.0 processor encountering a higher version declaration should try to switch to forwards compatible processing but I think libxslt does not do that.

So you will need to try to run the XSLT with Saxon 9 or 10, available for Java or .NET or as Saxon-C also with a PHP binding if you need to do it from PHP.

like image 60
Martin Honnen Avatar answered Dec 08 '25 22:12

Martin Honnen