Solved

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

Posted on 2009-05-16
3
233 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Wordpress Query 1 32
uploading multiple image with php 14 17
Instering to MySQL table 5 16
Import data into excel from web page 10 7
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now