From: c dot d at earthlink dot net
Operating system: Mac OS X 10.3.6
PHP version: 5.0.2
PHP Bug Type: XSLT related
Bug description: XSLTProcessor Not Recognizing DOMDocument Root
Description:
------------
If xml is created via a DOMDocument and then sent to a XSLTProcessor with
a XSL file, the following xsl code doesn't find the root node:
<xsl:template match="/">
<xsl:value-of select="childofroot"/>
</xsl:template>
You have to create a template for the root element (using it's name) and
use an apply-templates tag instead of value-of tag(s) in the root template
(such as above).
If identical xml is loaded from a file via DOMDocument->load the XSLT
processor processes the root element correctly.
Reproduce code:
---------------
<?php
$temp_DOM = new DomDocument("1.0");
$root = $temp_DOM->createElement("root");
$root = $temp_DOM->appendChild($root);
$element = $temp_DOM->createElement("fullname");
$element = $root->appendChild($element);
$text = $temp_DOM->createTextNode("John Doe");
$text = $element->appendChild($text);
$xsl_DOM = new DOMDocument;
$xsl_DOM->load("test.xsl");
$xslt = new XSLTProcessor();
$xslt->importStylesheet($xsl_DOM);
echo $xslt->transformToXML($temp_DOM);
?>
Contents of XSL File
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:value-of select="fullname"/>
</xsl:template>
</xsl:stylesheet>
Expected result:
----------------
Should output xml declaration and value of "fullname" element.
Actual result:
--------------
Only outputs xml declaration. Value of "fullname" element is not output.
--
Edit bug report at http://bugs.php.net/?id=30969&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30969&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=30969&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=30969&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30969&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30969&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30969&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30969&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30969&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30969&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30969&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=30969&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=30969&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30969&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30969&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30969&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30969&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30969&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30969&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30969&r=mysqlcfg