Jump to content

Using CURL and XSLT


tysontune

Recommended Posts

I'm building an application that is essentially a back end supplying xml to both flash and PHP.  The PHP front end is created through XSLT.  The xml files are output dynamically by setting the text/xml header in PHP.  Since the PHP page that does the xsl transform is on the same server as the xml producing back end, simple reading the xml files gives me the actual code contents of the file, not the compiled xml output.  To get around this, I have created a CURL function set that grabs the xml through http, which get's the correct data.  It also does this for the xsl files which are created with php files and output as text/xml as well.

I'm married to the xml return for this one since that is how the data gets into the Flash component, and the database caching system I have setup returns the xml as well.

So here's the question.  Am I creating too many requests to the server for this solution to scale?  In essence, you go to a page which calls two other pages via http, then does the transform.  This seems counter intuitive, but it is in widespread use with httprequest and ajax all over the web.

The alternate is to create the output each an xslt is called, but this seems like more strain on the server than simple requests.

Any idea what will scale better?
Link to comment
Share on other sites

If I understand you correctly you want:

$file = 'generate_xml.php';
ob_start();
include($file);
$xml = ob_get_contents();
ob_end_clean();

You might want to use set_error_handler to make sure the errors are displayed on the screen in not in $xml. You should also not send text/xml header in generate_xml.php by checking if basename($_SERVER['SCRIPT_FILENAME']) == __FILE__;

Hope this helps,
Arnold
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.