tags:

views:

332

answers:

3

I have a lots (500ish) xml files from An old ASP and VBscript that was running on an old windows server. The user could click a link to download the requested xml file, or click a link to view how the xml file will look, once its imported into their system...

If clicked to view the output, this opened a popup window were the xml filename is passed via URL & using the xslt template file this would display the output.

example url = /transform.php?action=transform&xmlProtocol=AC_Audiology.xml

Now were using PHP5 im trying to get something that resembles the same output. we started looking into xslt_create(); but this is an old function from php4

I'm looking for the best method to deploy this.

The main php page should check & capture the $_GET['xmlProtocol'] value. pass this to the xslt template page as data; were it will be output in html.

a general point in the right direction would be great!

+2  A: 

You can find the documentation (+examples) of the "new" XSL(T) extension at http://docs.php.net/xsl.

VolkerK
A: 

I had a similar problem about two years ago. I was using PHP5 but needed to use xslt_create(); or an equivalent. Ultimately, I switched to PHP4.

You can probably set your server to use PHP5 everywhere except for files in a certain folder. I believe that's what I did so I could process XSL files using PHP4 but the majority of the site still used PHP5.

It's possible that things have changed in the last two years and PHP5 has better support for something like xslt_create(); ---- I haven't been following recent changes.

Hope this helps!

mikey_w
+1  A: 

php

// Transform.php

if(isset($_GET['action']) && $_GET['action'] == 'transform') {

 // obviously you would never trust the input and would validate first
 $xml_file = AFunctionValidateAndGetPathToFile($_GET['xmlProtocol']);

 // Load up the XML File
 $xmlDoc = new DOMDocument;
 $xmlDoc->load($xml_file);

 // Load up the XSL file
 $xslDoc = new DomDocument;
 $xslDoc->load("xsl_template_file.xsl");
 $xsl = new XSLTProcessor;
 $xsl->importStyleSheet($xslDoc);

 // apply the transformation
 echo $xsl->transformToXml($xmlDoc);
}
frglps