ID: 40838 User updated by: korisu at gmail dot com Reported By: korisu at gmail dot com Status: Bogus Bug Type: XSLT related Operating System: Windows Vista PHP Version: 5.2.1 New Comment:
... So it is. Forgot that node() will match processing-instruction() and comment(), and this behavior comes from the <copy> element. Thanks! (and sorry about the bug-file) Previous Comments: ------------------------------------------------------------------------ [2007-03-16 17:29:11] [EMAIL PROTECTED] it's a libxslt issue, if at all, as you correctly realized by yourself. Please complain there, if you really think, it's a bug. But you have a <template match="node()"> matcher, which also matches to processing-instruction() and comment() nodes... If you change that to <template match="*|text()"> everything works like expected ------------------------------------------------------------------------ [2007-03-16 16:58:16] korisu at gmail dot com Description: ------------ The default (built-in) template for processing instructions and comments is not implemented in the current version of libxslt. The template should be as follows: <xsl:template match="processing-instruction()|comment()"/> This is defined in the W3C recommendation (http://www.w3.org/TR/xslt#built-in-rule). The files used in the test code can be found here: http://scott.trenda.net/xml/php-bug-report/test.php (source pasted to "Reproduce Code" section) http://scott.trenda.net/xml/php-bug-report/checkerboard.xml http://scott.trenda.net/xml/php-bug-report/checkerboard.xsl http://scott.trenda.net/xml/php-bug-report/checkerboard2.xsl This has been reproduced on Windows Vista, running 5.2.1 through IIS7 (ISAPI), and on Linux running 5.1.2 through Apache 2.0 (http://scott.trenda.net/phpinfo.php). Reproduce code: --------------- <?php $xslt = new xsltProcessor; ?> <div> <span>Incorrect transformation:</span> <div> <?php $xslt->importStyleSheet(DOMDocument::load("checkerboard.xsl")); echo $xslt->transformToXML(DOMDocument::load("checkerboard.xml")); ?> </div> <span>Correct transformation (built-in stylesheet explicitly defined in checkerboard2.xsl)</span> <div> <?php $xslt->importStyleSheet(DOMDocument::load("checkerboard2.xsl")); echo $xslt->transformToXML(DOMDocument::load("checkerboard.xml")); ?> </div> </div> Expected result: ---------------- The first example does not have a template defined for processing instructions and comments; if you view the source, you will see the xml-stylesheet processing instruction from the source, and the test comment following it: <?xml-stylesheet type="text/xsl" href="xslt/checkerboard.xsl"><!-- Testing comment template --> The second example has the template explicitly defined as per the W3C Recommendation; its source has neither the xml-stylesheet processing instruction nor the test comment. Actual result: -------------- <div> <span>Incorrect transformation:</span> <div> <?xml-stylesheet type="text/xsl" href="xslt/checkerboard.xsl"><!-- Testing comment template --><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style> table { border: 1px solid gray; border-collapse: collapse; } td { width: 40px; height: 40px; } .cell0 { background-color: black; } .cell1 { background-color: white; } </style> </head> <body><table> <tr> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> </tr> <tr> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> </tr> <tr> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> </tr> <tr> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> </tr> <tr> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> </tr> <tr> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> </tr> <tr> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> </tr> <tr> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> </tr> </table></body> </html> </div> <span>Correct transformation (built-in stylesheet explicitly defined in checkerboard2.xsl)</span> <div> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style> table { border: 1px solid gray; border-collapse: collapse; } td { width: 40px; height: 40px; } .cell0 { background-color: black; } .cell1 { background-color: white; } </style> </head> <body><table> <tr> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> </tr> <tr> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> </tr> <tr> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> </tr> <tr> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> </tr> <tr> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> </tr> <tr> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> </tr> <tr> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> </tr> <tr> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> <td class="cell1"></td> <td class="cell0"></td> </tr> </table></body> </html> </div> </div> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40838&edit=1
