简体   繁体   中英

XSL transformation in php5 WITHOUT the XSL extension enabled

I'm in front of a silly situation... I have to get an application performing XSLT transformations to run on an institutional server, and this server has php5 configured without XSL enabled... Changing the hosting solution is unfortunately not an option, and the IT people in charge of the server are not willing to reconfigure it and enable XSL.

So here's my dummy question: is it possible to perform an XSL transformation without XSL enabled? (to be precise, I need to transform XML strings with XSL files, if it matters) I have checked DOM, but the examples use the class that provokes a fatal error in my actual script (XSLTProcessor).

Any suggestion would be much appreciated.

There are some PEAR packages that deal with XML/XSLT. I don't have any personal experience with any of them, though.

http://pear.php.net/packages.php?catpid=22&catname=XML

Note that you don't need to install pear to get a pear package, you can download it manually.

I have never heard of a PHP implementation of an XSLT processor. If one existed, it would probably be complex, bugged and most likely unmaintained.

You should look into alternative solutions, such as using a remote server whose job is to perform the transformation (if that's applicable to your case) or perhaps using exec() to run a command line processor, if such a thing is possible.

Depending on the complexity of the transformation, you might be better off performing it in PHP with SimpleXML . I'm not talking about making an XSLT processor here, that would be crazy, simply instead of using something like

<xsl:for-each select="/foo/bar">
    <xsl:value-of select="@baz" />
</xsl:for-each>

you could use

foreach ($foo->bar as $bar) {
    echo $bar['baz'];
}

Of course, this is only a realistic solution if your stylesheet is very basic/simple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM