Forum Moderators: coopster

Message Too Old, No Replies

Help with XSLT and PHP

         

ryankask

12:53 am on Jun 14, 2004 (gmt 0)

10+ Year Member



I was reading another post about how to get the declarations to show when embedding PHP in an XML file. If you visit the following URL <snip> you will notice that everything is great (look at the source) but the XSLT document just doesn't seem to be working...help? By the way, it works without the PHP...

<?xml version="1.0"?>  
<?xml:stylesheet type="text/xsl" href="style.xsl"?>
<index>
<pageTitle>Ryan's Favorite Sites</pageTitle>
<header>
<text>Ryan's Favorites</text>
<version>1.0.1</version>
</header>
<main>
<site>

<name>example.com</name>
<desc>The greatest site for aviation in the world!</desc>
<addy>http://www.example.com</addy>
<dtad>2004-06-13 09:48:16</dtad>
</site>
<site>
<name>Yahoo!</name>

<desc>Yahoo is probably one of the best websites out there.</desc>
<addy>http://www.yahoo.com</addy>
<dtad>2004-06-13 10:07:37</dtad>
</site>
<site>
<name>Python.org</name>
<desc>Find out about the wonderful language of Python!</desc>

<addy>http://www.python.org</addy>
<dtad>2004-06-13 19:48:11</dtad>
</site>
</main>
<footer>
<copyright>Ryan Kaskel</copyright>
<year>2004</year>

</footer>
</index>

[edited by: jatar_k at 5:06 am (utc) on June 14, 2004]
[edit reason] removed url added actual source [/edit]

ryankask

2:30 pm on Jun 15, 2004 (gmt 0)

10+ Year Member



Can anyone help?

coopster

12:53 am on Jun 20, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, ryankask!

Is PHP installed and running on your server?

davidpbrown

12:08 pm on Jun 20, 2004 (gmt 0)

10+ Year Member



I'm not sure what you mean by "get the declarations to show when embedding PHP in an XML file".

If the URL is to the XML document, I would expect the PHP, if installed and working ok, to be processed before the XML/XSLT.
IE is the only browser I know, that will work the XSLT linked to an XML file it's opened.

I can't see in the edited post what the PHP is. Obviously, XML isn't XHTML so you don't want <!DOCTYPE HTML headers you only need the <?xml version="1.0"?>

ryankask

2:08 pm on Jun 20, 2004 (gmt 0)

10+ Year Member



Nevermind, the problem was solved. I have to echo any <?> statements (including the XML headers) but the main problem was that I needed to add a PHP header function as well...this is what the working result looks like..

<?php
header("Content-type: text/xml");

echo "<?xml version=\"1.0\"?> \n";
echo "<?xml-stylesheet type=\"text/xsl\" href=\"style.xsl\"?>";

.
.
.more code
.
.

?>