ID: 30969
Updated by: [EMAIL PROTECTED]
Reported By: c dot d at earthlink dot net
-Status: Open
+Status: Bogus
Bug Type: XSLT related
Operating System: Mac OS X 10.3.6
PHP Version: 5.0.2
New Comment:
Your XSLT is wrong.. It needs to be
<xsl:value-of select="root/fullname"/>
Your approach doesn't even work with xsltproc on the commandline.
and
"If identical xml is loaded from a file via DOMDocument->load the XSLT
processor processes the root element correctly."
Definitively not here on my system
Previous Comments:
------------------------------------------------------------------------
[2004-12-03 00:46:35] c dot d at earthlink dot net
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 this bug report at http://bugs.php.net/?id=30969&edit=1