View Full Version : Dynamic XSL - Mime Error
mindlessLemming
12-28-2004, 11:10 PM
Perhaps this should be in the PHP forum, I just think the audience here will be more likely to know the answer. (or just as likely..)
I'm using PHP to generate my XSL, adding this line to .htaccess to allow processing of XSL:
AddType application/x-httpd-php .php .xsl
And then this line should send the right header with the file:
header("Content-Type: text/xml");
The php is processing, and I can make dynamic CSS or JS files, so it's not my apache setup... but I get this error in the browser:
Error loading stylesheet: An XSLT stylesheet does not have an XML mimetype
I'm doing the transforms client-side, btw.
Little help? :o
Fou-Lu
12-31-2004, 12:04 PM
In that case it shouldn't be cause by your xmldom or anything of the sorts. I remember having a similar problem, and assuming of course that there is no output prior to this.
Now, I'm thinking its your application data. I think I had to change mine to a application/html+xml. Try using that instead, and honestly I'm not certain about the apache alterations there for your .htaccess, someone with more knowledge about that may be able to help. But yeah, you can have a .php extension outputing an xml page, it shouldn't cause you any grief, so I question as to whether you need the AddType in the apache addition at all (as long as your .php is included for processing)
Alex Vincent
01-02-2005, 07:54 AM
Actually, it should be application/xhtml+xml. :)
For the big mime-type, have you tried application/xml?
mindlessLemming
01-03-2005, 12:39 AM
Thanks guys, but none of those worked :(
I'm really stumped on this one -- surely you can serve dynamic XSL??!
My next move will be to move the transform to the server side and see what I can get away with there...
Thanks again :)
Fou-Lu
01-03-2005, 04:30 AM
Oops, my bad on that one! Lol
All this mime stuff is rather confusing though, are you just looking to administer xml/xsl through use of php? Cause thats a simple task!
You can do it server side if you have xml dom. Thats a whole task in itself though...
If client, you can do the same, you can take your xsl sheet (assuming this is the one you want to use, but you can use either, both, none or whatever), and you change it to php.
You include your xsl sheet as a .php extension instead. When loaded, you will have something of the sorts in your xsl.php sheet:
<?php
header("Content-type: text/xml");
$str = '<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
blah blah blah....
';
print($str);
The only difference I find when using xml within php is that you cannot... whats the best word for this... end your php to add different output:
...
?>
This has html stuff in it, and will be outputted immediatly to the browser
<?php
I find that all you need to do is remember that it has to be printed at the end, or your xml will lose its structure (probably confuses the <?php with the <?xml if your php.ini allows short tags).
Umm, hope that gives an idea for you. If not, you can post some code. Assuming that your xml is fine, this really is more of a php issue.
mindlessLemming
01-03-2005, 05:20 AM
I find that all you need to do is remember that it has to be printed at the end, or your xml will lose its structure (probably confuses the <?php with the <?xml if your php.ini allows short tags).
Short tags are off, but it may be that I'm not writing out all the xsl as one string; only the few dynamic parts are parsed.
Perhaps that's the ticket...
Either way, this is def a php issue, so lets lay this thread to rest ;)
Thanks for your help :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.