I have had a similar problem. I have an XML file that is successfully transformed using an XSL stylesheet, but when I copy that XML into a PHP file (and echo out the tags starting with <? ) it does not transform the XML.
I'm running IIS, so I don't know if .htaccess will work for me.
I have included examples below. The XSL stylesheet doesn't do much, I was just trying to do a case-in-point.
Here is the first bit of the plain XML.
Code:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="ScoTest.php"?>
<TestItems>
<item>
<itemId>0-48de9c82a963f</itemId>
<itemType>scriptMasculineFeminine</itemType>
<instructions>Identify whether the following word is masculine or feminine.</instructions>
<stimulus>
<stimulusType>script</stimulusType>
<stimulusLanguage>arabic</stimulusLanguage>
<stimulusValue> أنتِ </stimulusValue>
</stimulus>
<responses>
<responseType>text/script</responseType>
<responseLanguage>English</responseLanguage>
<response>
<correct>false</correct>
<responseValue>masculine</responseValue>
</response>
<response>
<correct>true</correct>
<responseValue>feminine</responseValue>
</response>
</responses>
</item>
...
...
Here is the first bit of the PHP.
PHP Code:
<?php
echo '<?xml version="1.0"?>\n';
echo '<?xml-stylesheet type="text/xsl" href="ScoTest.xsl"?>';
?>
<TestItems>
<item>
<itemId>0-48de9c82a963f</itemId>
<itemType>scriptMasculineFeminine</itemType>
<instructions>Identify whether the following word is masculine or feminine.</instructions>
<stimulus>
<stimulusType>script</stimulusType>
<stimulusLanguage>arabic</stimulusLanguage>
<stimulusValue> أنتِ </stimulusValue>
</stimulus>
<responses>
<responseType>text/script</responseType>
<responseLanguage>English</responseLanguage>
<response>
<correct>false</correct>
<responseValue>masculine</responseValue>
</response>
<response>
<correct>true</correct>
<responseValue>feminine</responseValue>
</response>
</responses>
</item>
Here is the stylesheet.
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"
encoding="utf-8"
omit-xml-declaration="yes" />
<xsl:template match="/">
<p class="header1">SCO Test</p>
<p>
<xsl:apply-templates />
</p>
</xsl:template>
<xsl:template match="item"><span class="tooltip"><xsl:value-of select="itemId" /><span class="tooltip_text"><xsl:value-of select="instructions" /></span></span><br /></xsl:template>
</xsl:stylesheet>
Like I said, the transformation works with the plain XML file, but not with the PHP file.