Forum Moderators: coopster

Message Too Old, No Replies

PHP - XML and XSL Transformation

         

ph_eze_nouz

11:42 am on Jul 6, 2004 (gmt 0)

10+ Year Member



Hi,

Is there a way to transform a XML using a XSL template using PHP4? Do you need to install external modules? Is the simpliest way to install PHP5?

Many thanks

pH

davidpbrown

11:59 am on Jul 6, 2004 (gmt 0)

10+ Year Member



I've no experience of server side XSLT processing but the XSLT FAQ - Server Side [dpawson.co.uk] suggests
Many XSLT processors come with built-in servlet support. For example, with SAXON, if you install the supplied SaxonServlet class in your servlets directory, then you can process an XML document simply by using a URL such as

mysite.com/servlets/SaxonServlet?source=source-url.xml&style=stylesheet.xsl

The output of the stylesheet processing will be displayed in the browser.

(I'm not sure what PHP can do with XSL that isn't better tackled by an XSLT processor)

ph_eze_nouz

12:52 pm on Jul 6, 2004 (gmt 0)

10+ Year Member



Hi David,

many thanks for this post ;) Also, I will prefer to use a full PHP environment (if possible) to do this transformation. I saw that in PHP5, you can load a XML and a XSL as:

<?php
/* Load the two XML sources */
$xml = new DomDocument; // from /ext/dom
$xml->load('example.xml');

$xsl = new DomDocument;
$xsl->load('example.xsl');

/* Configure the transformer */
$proc = new xsltprocessor;
$proc->importStyleSheet($xsl); // attach the xsl rules
echo $proc->transformToXML($xml); // actual transformation
?>

How present is PHP5 on the Internet? Any idea in PHP4?

Thx

pH

davidpbrown

1:03 pm on Jul 6, 2004 (gmt 0)

10+ Year Member



suggesting PHP can do XSLT!.. that's interesting.

Is yours not a question of whether you have PHP5 avaliable on your server? Pre-processing isn't something dependant on the client side.

ph_eze_nouz

4:04 pm on Jul 6, 2004 (gmt 0)

10+ Year Member



Hi,

I know that the pre-processing is based on the server ;) My concern is based on the scalability of the project. I wouldn't like to have the entire project based on PHP5 and then have all servers around providing only PHP4 ;)

I'll check how present is PHP5 before continuing ;)

In all the case, many thanks for your help ;)

pH