[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register 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
?
246 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

649 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