ID:               43289
 Updated by:       [EMAIL PROTECTED]
 Reported By:      maximchick at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         XSLT related
 Operating System: Gentoo Linux
 PHP Version:      5.2.5
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You are either modifying wrong document or don't understand than only 1
template is matched here. Either way the output is exactly as it should
be.


Previous Comments:
------------------------------------------------------------------------

[2007-11-14 08:23:47] maximchick at gmail dot com

Description:
------------
xsl:document('') function must return contents of the template itself
when the argument is empty string, but when i'm trying to modify
template DOM document('') returns contents of original xsl loaded by
DOMDocument::load() without my modifications.

Reproduce code:
---------------
$ cat /tmp/template.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="document('')//xsl:*"><xsl:value-of
select="name()"/><xsl:text>
</xsl:text></xsl:for-each>
</xsl:template>
</xsl:stylesheet>

$cat /tmp/template.php
<?php
$xml = new DOMDocument; //empty document (our stylesheet parses
itself)
$xml->load('/tmp/template.xsl');

$xsl = new DOMDocument;
$xsl->load('/tmp/template.xsl');

$xpath = new DOMXPath($xsl);
$xpath->registerNamespace('xsl','http://www.w3.org/1999/XSL/Transform');

$xpath->query('//xsl:stylesheet')->item(0)->appendChild($xpath->query('//xsl:template')->item(0)->cloneNode(true));

echo $xsl->saveXML(); //output changed xsl document

$proc = new XSLTProcessor();
$proc->importStylesheet($xsl);

echo $proc->transformToXML($xml);
?>

Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="document('')//xsl:*"><xsl:value-of
select="name()"/><xsl:text>
</xsl:text></xsl:for-each>
</xsl:template>
<xsl:template match="/">
<xsl:for-each select="document('')//xsl:*"><xsl:value-of
select="name()"/><xsl:text>
</xsl:text></xsl:for-each>
</xsl:template></xsl:stylesheet>
xsl:stylesheet
xsl:output
xsl:template
xsl:for-each
xsl:value-of
xsl:text
xsl:output
xsl:template
xsl:for-each
xsl:value-of
xsl:text

Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:for-each select="document('')//xsl:*"><xsl:value-of
select="name()"/><xsl:text>
</xsl:text></xsl:for-each>
</xsl:template>
<xsl:template match="/">
<xsl:for-each select="document('')//xsl:*"><xsl:value-of
select="name()"/><xsl:text>
</xsl:text></xsl:for-each>
</xsl:template></xsl:stylesheet>
xsl:stylesheet
xsl:output
xsl:template
xsl:for-each
xsl:value-of
xsl:text


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=43289&edit=1

Reply via email to