Solved

How do I make document() function work in XSLT with URL to PHP file?

Posted on 2009-05-16
3
236 Views
Last Modified: 2013-11-18
I am running an XML transformation in PHP5 (standard) with a stylesheet which "imports" external xml files using the document() function. The URL in the document() function is a reference to a PHP file, eg. <xsl:variable name="file" select="document('http://my-host.com/getXML.php?file=A123')". The PHP file gets the xml file from my database (based on session information).

I have set the http header for no caching, expiry in the past and content-type to text/xml in the PHP file.

When I acces the PHP URL directly in the browser I perfectly get my xml file.

But when doing the transformation the stylesheet does not get the xml.

What do I do wrong?
0
Comment
Question by:Henrik_Nyholm
  • 2
3 Comments
 
LVL 13

Assisted Solution

by:numberkruncher
numberkruncher earned 200 total points
ID: 24404312
Is the content type being set to "application/xml" by PHP?

i.e:
<?php
 
header('Content-type: application/xml');

Open in new window

0
 
LVL 13

Assisted Solution

by:numberkruncher
numberkruncher earned 200 total points
ID: 24404317
Sorry, in the above I meant to say, Have you tried setting the content type to "application/xml" instead of "text/xml" to see if it makes a difference.

Have you tried validating the XML that is generated by your PHP to verify that it is well formed?
0
 

Accepted Solution

by:
Henrik_Nyholm earned 0 total points
ID: 24405504
I actually found out what was the problem: sessions. Because the transformation runs on the server, the file requesting application is not the browser but the transformer component on the server which has no session; the browser has a session but this is not transfered to the transformer component.

So the transformation process runs on the server with no session even though the browser has a session, and therefore the transformation process gets no xml document based on session information.

When the xml request is not based on sessions everything works, even with no content header.

A little bit tricky... :-)
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question