Just upgraded to XAMPP v 1.7.0 for Windows (On XP Pro).
I keep receiving the error "Attribute nodes must be added before any child nodes to an element." when trying to do a simple XML/XSL transform using DOM via PHP.
When I manually specify an XSL in the XML file (<?xml:stylesheet type="text/xsl" href="a.xsl" ?>) and open it in IE, it displays fine.
When I try to do the transform through PHP, I get the results...
Warning: XSLTProcessor::transformToDoc() [xsltprocessor.transformtodoc]: runtime error: file file:///C:/xampp/htdocs/a.xsl line 7 element copy in C:\xampp\htdocs\a.php on line 9
Warning: XSLTProcessor::transformToDoc() [xsltprocessor.transformtodoc]: Attribute nodes must be added before any child nodes to an element. in C:\xampp\htdocs\a.php on line 9
I get this 5 times.
I don't know of anything I'm doing different that would cause the basic identity transform to fail. It was working in, I believe 1.6.6. I've tried uninstall/reinstall a few times.
I've made the test as simple as possible. As I said, it works through a manually specified XSL in the XML rendered through IE.
Thoughts, suggestions?
I simplified the test case to..
=== a.xml
<?xml version="1.0"?>
<x>
<bj j='1' k='k' m='m'>
<b nn='5'>ldkjslkj</b>
a;lksdjf;<i tttttttttttt='36'>asl</i>dkjf;lkasjdf
<r>R</r><hr/>
</bj>
</x>
=== a.xsl
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates select='*'/>
</xsl:template>
<xsl:template match='@*|node()'>
<xsl:value-of select='name()'/><xsl:copy><xsl:apply-templates select='@*|node()'/></xsl:copy>
</xsl:template>
</xsl:stylesheet>
=== a.php
<?
$xml = new DomDocument;
$xml->load("a.xml");
$xh = new XsltProcessor();
$xsl = new DomDocument;
$xsl->load("a.xsl");
$xh->registerPHPFunctions();
$xh->importStyleSheet($xsl);
$result = $xh->transformToDoc($xml);
unset($xh);
return $result;
?>