?
Solved

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

Posted on 2009-05-16
3
Medium Priority
?
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
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 learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

764 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