Page 1 of 1

XSL Identity Transform

PostPosted: 28. January 2009 10:24
by bhoogter
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;
?>

Re: XSL Identity Transform

PostPosted: 28. January 2009 10:36
by Izzy
There is a php_domxml.dll extension in the xampp\apache\bin\php.ini file that is commented out and has been the default for a few versions.

Never used it but you may try uncommenting this extension and try again.

If you find it does not help then simply comment it out again.

Save the file and restart Apache.

There are also another couple of extension for xml further down the list, some uncommented and another commented out.

Please let us know back if this helps.
Thanks

Re: XSL Identity Transform

PostPosted: 28. January 2009 10:54
by bhoogter
Okay.. Tried that, and verified the module loaded.... It appears that that DOMXML is something older, perhaps a PHP4 remnant, because it changed the
error messages to....

Warning: domdocument::domdocument() expects at least 1 parameter, 0 given in C:\xampp\htdocs\a.php on line 2
Fatal error: Call to undefined method domdocument::load() in C:\xampp\htdocs\a.php on line 3

So, it looks like it changed the interface altogether.

Re: XSL Identity Transform

PostPosted: 28. January 2009 10:59
by Izzy
Yes I recall that it was commented out by default because of that error popping up all the time.

Is there perhaps a new version out there on the net somewhere I wonder?

Sorry I can't help, still trapped in html and xhtml I'm afraid.

There are some gurus who frequent the forums but how often is another matter.

Best of luck with it.

Re: XSL Identity Transform

PostPosted: 29. January 2009 05:00
by bhoogter
I uninstalled 1.7.0 and reinstalled 1.6.6 and the same transform works fine (as well as my larger case).

Is this a problem with the DOM module (I believe the XML processing I'm using is from the DOM) for PHP?

Re: XSL Identity Transform

PostPosted: 29. January 2009 08:35
by Izzy
You could report this possible bug here but it's temporarily off line at the moment.
http://bugs.xampp.org/

Try writing to Oswald the lead Developer by email, address on the Contact page at Apache Friends home page as the developers often miss bug report post.

Give as much relevant detail as possible.

BTW there is currently a new beta bug fix release available where if it is still evident in this beta then there is a facility to report it on the beta page.
http://www.apachefriends.org/en/xampp-beta.html

Best wishes.

Re: XSL Identity Transform

PostPosted: 29. January 2009 23:02
by bhoogter
Thanks for the help.

I tried on a new machine with the beta, and same problem. Tried bug reporting on the form there (wasn't sure it was the appropriate place), but the beta page's reporting form failed to send [unknown email address or something]. Will keep my eye posted for more insight and for the bug-reporting to work again.

Re: XSL Identity Transform

PostPosted: 01. February 2009 15:48
by Oswald
Fixed the issue with the beta feedback form. Thanks!!!