[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-05-16
3
Medium Priority
?
248 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 800 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 800 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 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