View Single Post

  #3 (permalink)  
Old 09-06-2004
Janwillem Borleffs
 
Posts: n/a
Default Re: XSLT processing instruction to use PHP

Janwillem Borleffs wrote:
> And yes, this requires the parsing of the stylesheet to be done by
> PHP's XSLT extension...
>


I have found another way, using the PHP cli and msxsl (an msxml wrapper),
without the need to have the XSLT extension installed:

XSLT (test.xslt):
====
<?xml version="1.0" encoding="iso-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<?php echo "test"?>
</xsl:template>
</xsl:stylesheet>

XML (test.xml, just to have something to work with):
====
<?xml version="1.0" encoding="iso-8859-1" ?>
<root />

Command line:
==========
> php test.xslt | msxsl -o test.html test.xml -


When you have the short_open_tag directive enabled in your php.ini file, you
can disable it temporary using the -d option:

> php -d short_open_tag=off test.xslt | msxsl -o test.html test.xml -


This way, test.xslt gets parsed by the PHP interpreter first and the output
is catched by msxsl (indicated by the last hyphen). The generated test.html
will contain the following:

<?xml version="1.0" encoding="UTF-16"?>
test

Needless to mention that this example only works on Windows platforms.

Perhaps this is useful to you...


JW



Reply With Quote